advapi32: Do not call MIDL_user_free() with pointer to stack memory
Andrew Talbot
andrew.talbot at talbotville.com
Sat Apr 5 17:46:41 CDT 2008
Changelog:
advapi32: Do not call MIDL_user_free() with pointer to stack memory.
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;
More information about the wine-patches
mailing list