Commit 101fe51b authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit: Correctly calculate REG_MULTI_SZ size before reading from the buffer.

parent 159f3699
...@@ -312,12 +312,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -312,12 +312,12 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
WCHAR *tmpValueData = NULL; WCHAR *tmpValueData = NULL;
INT i, j, count; INT i, j, count;
for ( i = 0, count = 0; i < len - 1; i++) for (i = 0, count = 0; i < len / sizeof(WCHAR); i++)
if ( !stringValueData[i] && stringValueData[i + 1] ) if ( !stringValueData[i] && stringValueData[i + 1] )
count++; count++;
tmpValueData = heap_xalloc((len + count) * sizeof(WCHAR)); tmpValueData = heap_xalloc(len + (count * sizeof(WCHAR)));
for ( i = 0, j = 0; i < len - 1; i++) for ( i = 0, j = 0; i < len / sizeof(WCHAR); i++)
{ {
if ( !stringValueData[i] && stringValueData[i + 1]) if ( !stringValueData[i] && stringValueData[i + 1])
{ {
...@@ -327,7 +327,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -327,7 +327,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
else else
tmpValueData[j++] = stringValueData[i]; tmpValueData[j++] = stringValueData[i];
} }
tmpValueData[j] = stringValueData[i];
heap_free(stringValueData); heap_free(stringValueData);
stringValueData = tmpValueData; stringValueData = tmpValueData;
tmpValueData = NULL; tmpValueData = NULL;
...@@ -337,7 +337,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -337,7 +337,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
len = lstrlenW( stringValueData ); len = lstrlenW( stringValueData );
tmpValueData = heap_xalloc((len + 2) * sizeof(WCHAR)); tmpValueData = heap_xalloc((len + 2) * sizeof(WCHAR));
for ( i = 0, j = 0; i < len - 1; i++) for (i = 0, j = 0; i < len; i++)
{ {
if ( stringValueData[i] == char1 && stringValueData[i + 1] == char2) if ( stringValueData[i] == char1 && stringValueData[i + 1] == char2)
{ {
...@@ -348,7 +348,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -348,7 +348,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
else else
tmpValueData[j++] = stringValueData[i]; tmpValueData[j++] = stringValueData[i];
} }
tmpValueData[j++] = stringValueData[i];
tmpValueData[j++] = 0; tmpValueData[j++] = 0;
tmpValueData[j++] = 0; tmpValueData[j++] = 0;
heap_free(stringValueData); heap_free(stringValueData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment