Title: [140922] trunk/Source/WebKit2
Revision
140922
Author
wei...@apple.com
Date
2013-01-26 17:36:36 -0800 (Sat, 26 Jan 2013)

Log Message

Simplify environment creation in XPC service re-exec
https://bugs.webkit.org/show_bug.cgi?id=108017

Reviewed by Dan Bernstein.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:
(WebKit::XPCServiceEventHandler):
There is no need to copy these strings.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (140921 => 140922)


--- trunk/Source/WebKit2/ChangeLog	2013-01-27 01:01:08 UTC (rev 140921)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-27 01:36:36 UTC (rev 140922)
@@ -1,3 +1,14 @@
+2013-01-26  Sam Weinig  <s...@webkit.org>
+
+        Simplify environment creation in XPC service re-exec
+        https://bugs.webkit.org/show_bug.cgi?id=108017
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h:
+        (WebKit::XPCServiceEventHandler):
+        There is no need to copy these strings.
+
 2013-01-26  Alexey Proskuryakov  <a...@apple.com>
 
         Remove code for handling NetworkProcess authentication challenges in WebProcess

Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h (140921 => 140922)


--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h	2013-01-27 01:01:08 UTC (rev 140921)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceBootstrapper.Development.h	2013-01-27 01:36:36 UTC (rev 140922)
@@ -96,21 +96,13 @@
                 xpc_object_t environmentArray = xpc_dictionary_get_value(event, "environment");
                 size_t numberOfEnvironmentVariables = xpc_array_get_count(environmentArray);
 
-                char** environment = (char**)malloc(numberOfEnvironmentVariables * sizeof(char*) + 1);
-                for (size_t i = 0; i < numberOfEnvironmentVariables; ++i) {
-                    const char* string =  xpc_array_get_string(environmentArray, i);
-                    size_t stringLength = strlen(string);
-
-                    char* environmentVariable = (char*)malloc(stringLength + 1);
-                    memcpy(environmentVariable, string, stringLength);
-                    environmentVariable[stringLength] = '\0';
-
-                    environment[i] = environmentVariable;
-                }
+                const char** environment = (const char**)malloc(numberOfEnvironmentVariables * sizeof(char*) + 1);
+                for (size_t i = 0; i < numberOfEnvironmentVariables; ++i)
+                    environment[i] = xpc_array_get_string(environmentArray, i);
                 environment[numberOfEnvironmentVariables] = 0;
 
                 pid_t processIdentifier = 0;
-                posix_spawn(&processIdentifier, path, 0, &attr, const_cast<char**>(args), environment);
+                posix_spawn(&processIdentifier, path, 0, &attr, const_cast<char**>(args), const_cast<char**>(environment));
 
                 posix_spawnattr_destroy(&attr);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to