Revision
974
Author
kvv@apple.com
Date
2011-11-10 13:14:58 -0800 (Thu, 10 Nov 2011)

Log Message

- darwintrace: crash in darwintrace_make_environ

Modified Paths

Diff

Modified: branches/PR-10412066/CHANGES (973 => 974)


--- branches/PR-10412066/CHANGES	2011-11-09 22:53:31 UTC (rev 973)
+++ branches/PR-10412066/CHANGES	2011-11-10 21:14:58 UTC (rev 974)
@@ -1,5 +1,8 @@
 Darwin Build Scripts Change History
 -----------------------------------
+Release 26.x [9-Nov-2011]
+	- darwintrace: crash in darwintrace_make_environ
+
 Release 26.1 [7-Nov-2011]
 	- darwintrace: compiler warning build fix
 

Modified: branches/PR-10412066/darwintrace/darwintrace.c (973 => 974)


--- branches/PR-10412066/darwintrace/darwintrace.c	2011-11-09 22:53:31 UTC (rev 973)
+++ branches/PR-10412066/darwintrace/darwintrace.c	2011-11-10 21:14:58 UTC (rev 974)
@@ -405,20 +405,22 @@
             result[i] = strdup(DARWINTRACE_PLACEHOLDER);
         }
         ++i;
-        
+
         if (darwintrace_dylib_path) {
-            int add_dylib = (strstr(libs, darwintrace_dylib_path) == NULL);
-            asprintf(&result[i],
-                     "%s%s%s%s",
-                     DYLD_INSERT_LIBRARIES,
-                     add_dylib ? darwintrace_dylib_path : "",
-                     (add_dylib && libs) ? ":" : "",
-                     libs ? libs : "");
+            if (libs && strstr(libs, darwintrace_dylib_path)) {
+                /* inserted libraries already contain dylib */
+                result[i] = strdup(DARWINTRACE_PLACEHOLDER);
+            } else {
+                /* otherwise set or insert the dylib path */
+                asprintf(&result[i], "%s%s%s%s",
+                        DYLD_INSERT_LIBRARIES, darwintrace_dylib_path,
+                        libs ? ":" : "", libs ? libs : "");
+            }
         } else {
             result[i] = strdup(DARWINTRACE_PLACEHOLDER);
         }
         ++i;
-        
+
         memcpy(&result[i], envp, count * sizeof(char *));
 
         while (result[i] != NULL) {