kernel32: Prevent null pointer dereference in WritePrivateProfileStructW.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49285 Signed-off-by: Fabian Maurer <dark.shadow4@web.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
65954db2be
commit
f391e9cf1e
|
@ -2044,9 +2044,14 @@ BOOL WINAPI WritePrivateProfileStructW (LPCWSTR section, LPCWSTR key,
|
|||
LPWSTR outstring, p;
|
||||
DWORD sum = 0;
|
||||
|
||||
TRACE("(%s %s %p %u %s)\n", debugstr_w(section), debugstr_w(key), buf, bufsize, debugstr_w(filename));
|
||||
|
||||
if (!section && !key && !buf) /* flush the cache */
|
||||
return WritePrivateProfileStringW( NULL, NULL, NULL, filename );
|
||||
|
||||
if (!buf)
|
||||
return WritePrivateProfileStringW(section, key, NULL, filename);
|
||||
|
||||
/* allocate string buffer for hex chars + checksum hex char + '\0' */
|
||||
outstring = HeapAlloc( GetProcessHeap(), 0, (bufsize*2 + 2 + 1) * sizeof(WCHAR) );
|
||||
p = outstring;
|
||||
|
|
|
@ -1109,6 +1109,7 @@ static void test_WritePrivateProfileString(void)
|
|||
static void test_profile_struct(void)
|
||||
{
|
||||
static const char expect_data[] = "[s]\r\nkey=616261637573006F\r\n";
|
||||
static const char expect_data_empty[] = "[s]\r\n";
|
||||
char buffer[20];
|
||||
BOOL ret;
|
||||
|
||||
|
@ -1173,6 +1174,11 @@ static void test_profile_struct(void)
|
|||
ok(!ret, "expected failure\n");
|
||||
todo_wine ok(GetLastError() == ERROR_BAD_LENGTH, "got error %lu\n", GetLastError());
|
||||
|
||||
/* Test deleting struct */
|
||||
ret = WritePrivateProfileStructA("s", "key", NULL, sizeof("abacus"), "./winetest.ini");
|
||||
ok(ret, "got error %lu\n", GetLastError());
|
||||
ok(check_file_data("./winetest.ini", expect_data_empty), "file doesn't match\n");
|
||||
|
||||
ret = DeleteFileA("./winetest.ini");
|
||||
ok(ret, "got error %lu\n", GetLastError());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue