Nikolay Sivov : wshom.ocx: Fix BSTR allocation for string registry values (Valgrind).
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Apr 21 09:57:27 CDT 2015
Module: wine
Branch: master
Commit: a8150b53b67b30cf87c4c401c66aade9af751ddd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a8150b53b67b30cf87c4c401c66aade9af751ddd
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Apr 20 15:53:32 2015 +0300
wshom.ocx: Fix BSTR allocation for string registry values (Valgrind).
---
dlls/wshom.ocx/shell.c | 2 +-
dlls/wshom.ocx/tests/wshom.c | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index 826e290..f9ec9dc 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -1376,7 +1376,7 @@ static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR name, VARIANT *v
case REG_SZ:
case REG_EXPAND_SZ:
V_VT(value) = VT_BSTR;
- V_BSTR(value) = SysAllocStringLen((WCHAR*)data, datalen - sizeof(WCHAR));
+ V_BSTR(value) = SysAllocString((WCHAR*)data);
if (!V_BSTR(value))
hr = E_OUTOFMEMORY;
break;
diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c
index 9591c5c..46ffc58 100644
--- a/dlls/wshom.ocx/tests/wshom.c
+++ b/dlls/wshom.ocx/tests/wshom.c
@@ -276,7 +276,7 @@ static void test_registry(void)
{
static const WCHAR keypathW[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\',
'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','T','e','s','t','\\',0};
-
+ static const WCHAR regsz2W[] = {'r','e','g','s','z','2',0};
static const WCHAR regszW[] = {'r','e','g','s','z',0};
static const WCHAR regdwordW[] = {'r','e','g','d','w','o','r','d',0};
static const WCHAR regbinaryW[] = {'r','e','g','b','i','n','a','r','y',0};
@@ -332,6 +332,9 @@ static void test_registry(void)
ret = RegSetValueExA(root, "regsz", 0, REG_SZ, (const BYTE*)"foobar", 7);
ok(ret == 0, "got %d\n", ret);
+ ret = RegSetValueExA(root, "regsz2", 0, REG_SZ, (const BYTE*)"foobar\0f", 9);
+ ok(ret == 0, "got %d\n", ret);
+
ret = RegSetValueExA(root, "regmultisz", 0, REG_MULTI_SZ, (const BYTE*)"foo\0bar\0", 9);
ok(ret == 0, "got %d\n", ret);
@@ -355,6 +358,18 @@ static void test_registry(void)
VariantClear(&value);
SysFreeString(name);
+ /* REG_SZ with embedded NULL */
+ lstrcpyW(pathW, keypathW);
+ lstrcatW(pathW, regsz2W);
+ name = SysAllocString(pathW);
+ VariantInit(&value);
+ hr = IWshShell3_RegRead(sh3, name, &value);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(V_VT(&value) == VT_BSTR, "got %d\n", V_VT(&value));
+ ok(SysStringLen(V_BSTR(&value)) == 6, "len %d\n", SysStringLen(V_BSTR(&value)));
+ VariantClear(&value);
+ SysFreeString(name);
+
/* REG_DWORD */
lstrcpyW(pathW, keypathW);
lstrcatW(pathW, regdwordW);
More information about the wine-cvs
mailing list