[PATCH 0/1] MR5490: setupapi: Don't set RequiredSize when SetupDiGetClassDescription* fails.
Discovered while investigating Bug 56551. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5490
From: Alex Henrie <alexhenrie24(a)gmail.com> Discovered while investigating Bug 56551. --- dlls/setupapi/devinst.c | 4 ++-- dlls/setupapi/tests/devinst.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index 7e2d683daa6..ea51e02086b 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -2135,7 +2135,7 @@ BOOL WINAPI SetupDiGetClassDescriptionExA( dwLength = ClassDescriptionSize; ret = !RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)ClassDescription, &dwLength ); - if (RequiredSize) *RequiredSize = dwLength; + if (ret && RequiredSize) *RequiredSize = dwLength; RegCloseKey(hKey); return ret; } @@ -2169,7 +2169,7 @@ BOOL WINAPI SetupDiGetClassDescriptionExW( dwLength = ClassDescriptionSize * sizeof(WCHAR); ret = !RegQueryValueExW( hKey, NULL, NULL, NULL, (LPBYTE)ClassDescription, &dwLength ); - if (RequiredSize) *RequiredSize = dwLength / sizeof(WCHAR); + if (ret && RequiredSize) *RequiredSize = dwLength / sizeof(WCHAR); RegCloseKey(hKey); return ret; } diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 2dc891d61f1..f568c7dd848 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -115,6 +115,7 @@ static void test_open_class_key(void) { static const char guidstr[] = "{6a55b5a4-3f65-11db-b704-0011955c2bdb}"; HKEY root_key, class_key; + DWORD size; LONG res; SetLastError(0xdeadbeef); @@ -135,6 +136,11 @@ static void test_open_class_key(void) ok(class_key != INVALID_HANDLE_VALUE, "Failed to open class key, error %#lx.\n", GetLastError()); RegCloseKey(class_key); + size = 123; + res = SetupDiGetClassDescriptionA(&guid, NULL, 0, &size); + ok(!res, "Expected failure.\n"); + ok(size == 123, "Expected 123, got %ld.\n", size); + RegDeleteKeyA(root_key, guidstr); RegCloseKey(root_key); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5490
Can we check the last error, please? What if the buffer is too short? Isn't that supposed to write the required size? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5490#note_68520
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Elizabeth Figura (@zfigura)