Andrew Talbot : advapi32: Do not call MIDL_user_free() with pointer to stack memory.

Alexandre Julliard julliard at winehq.org
Mon Apr 7 06:51:08 CDT 2008


Module: wine
Branch: master
Commit: 2ae8e87616d58fbcce647a013679b8b48dc35e72
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2ae8e87616d58fbcce647a013679b8b48dc35e72

Author: Andrew Talbot <andrew.talbot at talbotville.com>
Date:   Sat Apr  5 23:46:41 2008 +0100

advapi32: Do not call MIDL_user_free() with pointer to stack memory.

---

 dlls/advapi32/service.c       |   16 ++++++++++------
 dlls/advapi32/tests/service.c |    4 ++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c
index 77dc30b..78d057d 100644
--- a/dlls/advapi32/service.c
+++ b/dlls/advapi32/service.c
@@ -1352,15 +1352,19 @@ done:
 static DWORD move_string_to_buffer(BYTE **buf, LPWSTR *string_ptr)
 {
     DWORD cb;
-    WCHAR empty_str[] = {0};
 
     if (!*string_ptr)
-        *string_ptr = empty_str;
-
-    cb = (strlenW(*string_ptr) + 1)*sizeof(WCHAR);
+    {
+        cb = sizeof(WCHAR);
+        memset(*buf, 0, cb);
+    }
+    else
+    {
+        cb = (strlenW(*string_ptr) + 1)*sizeof(WCHAR);
+        memcpy(*buf, *string_ptr, cb);
+        MIDL_user_free(*string_ptr);
+    }
 
-    memcpy(*buf, *string_ptr, cb);
-    MIDL_user_free(*string_ptr);
     *string_ptr = (LPWSTR)*buf;
     *buf += cb;
 
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index 5eaf2f4..d299d2d 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -857,12 +857,12 @@ static void test_sequence(void)
     SetLastError(0xdeadbeef);
     ret = QueryServiceConfigA(svc_handle, config, given, &needed);
     ok(ret, "Expected success\n");
-    todo_wine
-    {
     ok(GetLastError() == ERROR_SUCCESS    /* W2K3 */||
        GetLastError() == 0xdeadbeef       /* NT4, XP, Vista */ ||
        GetLastError() == ERROR_IO_PENDING /* W2K */,
         "Expected ERROR_SUCCESS, ERROR_IO_PENDING or 0xdeadbeef, got %d\n", GetLastError());
+    todo_wine
+    {
     ok(given == needed, "Expected the given (%d) and needed (%d) buffersizes to be equal\n", given, needed);
     }
     ok(config->lpBinaryPathName && config->lpLoadOrderGroup && config->lpDependencies && config->lpServiceStartName &&




More information about the wine-cvs mailing list