Fixed an off-by-(sizeof(char*) - 1) bug.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 01:10:07 +0000 (01:10 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 01:10:07 +0000 (01:10 +0000)
Reviewed by Sam Weinig.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
(WebKit::XPCServiceEventHandler): Allocate a sufficiently large buffer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153969 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm

index f2e4cc1..e1ad27f 100644 (file)
@@ -1,3 +1,12 @@
+2013-08-12  Dan Bernstein  <mitz@apple.com>
+
+        Fixed an off-by-(sizeof(char*) - 1) bug.
+
+        Reviewed by Sam Weinig.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
+        (WebKit::XPCServiceEventHandler): Allocate a sufficiently large buffer.
+
 2013-08-12  Beth Dakin  <bdakin@apple.com>
 
         Remove didNewFirstVisuallyNonEmptyLayout from WebKit2
index ec2016d..cdebe7c 100644 (file)
@@ -108,7 +108,7 @@ static void XPCServiceEventHandler(xpc_connection_t peer)
 
                 xpc_object_t environmentArray = xpc_dictionary_get_value(event, "environment");
                 size_t numberOfEnvironmentVariables = xpc_array_get_count(environmentArray);
-                char** environment = static_cast<char **>(malloc(numberOfEnvironmentVariables * sizeof(char*) + 1));
+                char** environment = static_cast<char **>(malloc((numberOfEnvironmentVariables + 1) * sizeof(char*)));
                 for (size_t i = 0; i < numberOfEnvironmentVariables; ++i)
                     environment[i] = strdup(xpc_array_get_string(environmentArray, i));
                 environment[numberOfEnvironmentVariables] = 0;