harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r959836 - /harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c
Date Fri, 02 Jul 2010 03:17:56 GMT
Author: regisxu
Date: Fri Jul  2 03:17:54 2010
New Revision: 959836

URL: http://svn.apache.org/viewvc?rev=959836&view=rev
Log:
malloc incorrect size of memory in atoe_execvp and atoe_execv, and free memeory if exec is
failed.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c

Modified: harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c?rev=959836&r1=959835&r2=959836&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c (original)
+++ harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/a2e/unix/atoe.c Fri
Jul  2 03:17:54 2010
@@ -2040,7 +2040,7 @@ atoe_execv (const char *path, char *cons
     }
 
     /* Allocate space for the new array and populate */
-    ebcdicArgv = (char**) malloc(size+1);
+    ebcdicArgv = (char**) malloc(sizeof(char*) * (size+1));
     for (i=0; i<size; i++) {
         *(ebcdicArgv+i) = strdup(a2e_string(argv[i]));
     }
@@ -2050,6 +2050,11 @@ atoe_execv (const char *path, char *cons
 
     rc = execv(ebcdicPath, ebcdicArgv);
 
+    for (i = 0; i < size; ++i) {
+        free(*(ebcdicArgv + i));
+    }
+    free(ebcdicArgv);
+
     return rc;
 }
 
@@ -2072,7 +2077,7 @@ atoe_execvp (const char *file, char *con
     }
 
     /* Allocate space for the new array and populate */
-    ebcdicArgv = (char**) malloc(size+1);
+    ebcdicArgv = (char**) malloc(sizeof(char*) * (size+1));
     for (i=0; i<size; i++) {
         *(ebcdicArgv+i) = strdup(a2e_string(argv[i]));
     }
@@ -2082,6 +2087,11 @@ atoe_execvp (const char *file, char *con
 
     rc = execvp(ebcdicFile, ebcdicArgv);
 
+    for (i = 0; i < size; ++i) {
+        free(*(ebcdicArgv + i));
+    }
+    free(ebcdicArgv);
+
     return rc;
 }
 



Mime
View raw message