odbccp32: Handle NULL sizeout in SQLGetInstalledDrivers.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48111
Signed-off-by: Gijs Vermeulen <gijsvrm@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2019-11-16 17:08:44 +01:00 committed by Alexandre Julliard
parent df3c911c63
commit 3915b8d229
2 changed files with 7 additions and 1 deletions

View File

@ -583,7 +583,8 @@ BOOL WINAPI SQLGetInstalledDrivers(char *buf, WORD size, WORD *sizeout)
return FALSE;
}
*sizeout = WideCharToMultiByte(CP_ACP, 0, wbuf, written, NULL, 0, NULL, NULL);
if (sizeout)
*sizeout = WideCharToMultiByte(CP_ACP, 0, wbuf, written, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, wbuf, written, buf, size, NULL, NULL);
heap_free(wbuf);

View File

@ -643,6 +643,11 @@ static void test_SQLGetInstalledDrivers(void)
ok(!ret, "got %d\n", ret);
check_error(ODBC_ERROR_INVALID_BUFF_LEN);
ret = SQLGetInstalledDrivers(buffer, 10, NULL);
ok(ret, "got %d\n", ret);
ok(strlen(buffer) == 8, "got len %u\n", lstrlenA(buffer));
ok(!buffer[9], "buffer not doubly null-terminated\n");
ret = SQLGetInstalledDrivers(buffer, 10, &written);
ok(ret, "got %d\n", ret);
ok(strlen(buffer) == 8, "got len %u\n", lstrlenA(buffer));