OSSP CVS Repository

ossp - Check-in [3391]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3391
Date: 2003-May-27 16:51:38 (local)
2003-May-27 14:51:38 (UTC)
User:ms
Branch:
Comment: Fix vector copy terminate bug, and add checks to processor.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_anal.c      1.15 -> 1.16     5 inserted, 2 deleted
ossp-pkg/rc/rc_util.c      1.8 -> 1.9     4 inserted, 3 deleted

ossp-pkg/rc/rc_anal.c 1.15 -> 1.16

--- rc_anal.c    2003/05/26 16:03:56     1.15
+++ rc_anal.c    2003/05/27 14:51:38     1.16
@@ -247,8 +247,11 @@
 /*        just copies of the stack parameters passed in.         */
     int nIter = 0;
 
-    while (pInst->m_szRcs[nIter])   /* Rc file names       */
-        free(pInst->m_szRcs[nIter++]);
+    assert(pInst); /* Verify sanity */
+
+    if (pInst->m_szRcs && pInst->m_szRcs[nIter])
+        while (pInst->m_szRcs[nIter]) /* Rc file names     */
+            free(pInst->m_szRcs[nIter++]);
     if (pInst->m_szRcs)             /* Rc file name index  */
         free(pInst->m_szRcs);
     if (pInst->m_szTmp)             /* Temp file name      */


ossp-pkg/rc/rc_util.c 1.8 -> 1.9

--- rc_util.c    2003/05/20 17:14:17     1.8
+++ rc_util.c    2003/05/27 14:51:38     1.9
@@ -57,6 +57,7 @@
 {
     int nSecs  = 0;
     int nIndex = 0;
+    size_t nBytes  = 0;
     char **pszTemp = NULL;
 
     if (kpszVec) {
@@ -64,9 +65,9 @@
         pszTemp = malloc(sizeof (char **) * nSecs + 1);
 
         for (nIndex = 0; kpszVec[nIndex]; nIndex++) {           /* Copy loop */
-            pszTemp[nIndex] = malloc(strlen(kpszVec[nIndex]));  /* for each  */
-            memcpy(pszTemp[nIndex], kpszVec[nIndex],            /* element   */
-                   strlen(kpszVec[nIndex]));                    /* in vector */
+            nBytes = (strlen(kpszVec[nIndex]) + 1) * sizeof(char); /* for each */
+            pszTemp[nIndex] = malloc(nBytes);                   /* element   */
+            memcpy(pszTemp[nIndex], kpszVec[nIndex], nBytes);   /* in vector */
         }
         pszTemp[nIndex] = NULL; /* Used later to find the end of the array */
         return(pszTemp);        /* Success */

CVSTrac 2.0.1