setupapi: Avoid crash in SetupCloseInfFile.

This commit is contained in:
Detlef Riekenberg 2007-07-09 19:31:23 +02:00 committed by Alexandre Julliard
parent 9dedfd71e0
commit 8be4e8537c
2 changed files with 6 additions and 1 deletions

View file

@ -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 );

View file

@ -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"