diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c index 6ddc1f2550f..ea410f857b0 100644 --- a/dlls/setupapi/parser.c +++ b/dlls/setupapi/parser.c @@ -1231,7 +1231,7 @@ void WINAPI SetupCloseInfFile( HINF hinf ) struct inf_file *file = hinf; unsigned int i; - if (!file) return; + if (!hinf || (hinf == INVALID_HANDLE_VALUE)) return; for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] ); HeapFree( GetProcessHeap(), 0, file->filename ); diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c index 2bb493e7198..2585f6d6478 100644 --- a/dlls/setupapi/tests/parser.c +++ b/dlls/setupapi/tests/parser.c @@ -405,6 +405,11 @@ static void test_close_inf_file(void) SetLastError(0xdeadbeef); SetupCloseInfFile(NULL); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + SetupCloseInfFile(INVALID_HANDLE_VALUE); + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %u\n", GetLastError()); + } static const char *contents = "[Version]\n"