Some more error checking...
authorHervé Poussineau <hpoussin@reactos.org>
Thu, 11 May 2006 17:43:31 +0000 (17:43 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Thu, 11 May 2006 17:43:31 +0000 (17:43 +0000)
svn path=/trunk/; revision=21889

reactos/dll/win32/setupapi/parser.c

index ff30c63..c7f1d7e 100644 (file)
@@ -1302,12 +1302,15 @@ void WINAPI SetupCloseInfFile( HINF hinf )
     struct inf_file *file = hinf;
     unsigned int i;
 
     struct inf_file *file = hinf;
     unsigned int i;
 
-    for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
-    HeapFree( GetProcessHeap(), 0, file->filename );
-    HeapFree( GetProcessHeap(), 0, file->sections );
-    HeapFree( GetProcessHeap(), 0, file->fields );
-    HeapFree( GetProcessHeap(), 0, file->strings );
-    HeapFree( GetProcessHeap(), 0, file );
+    if (file != NULL)
+    {
+        for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
+        HeapFree( GetProcessHeap(), 0, file->filename );
+        HeapFree( GetProcessHeap(), 0, file->sections );
+        HeapFree( GetProcessHeap(), 0, file->fields );
+        HeapFree( GetProcessHeap(), 0, file->strings );
+        HeapFree( GetProcessHeap(), 0, file );
+    }
 }
 
 
 }
 
 
@@ -1339,6 +1342,9 @@ LONG WINAPI SetupGetLineCountW( HINF hinf, PCWSTR section )
     int section_index;
     LONG ret = -1;
 
     int section_index;
     LONG ret = -1;
 
+    if (hinf == NULL || hinf == INVALID_HANDLE_VALUE)
+        return ERROR_INVALID_PARAMETER;
+
     for (file = hinf; file; file = file->next)
     {
         if ((section_index = find_section( file, section )) == -1) continue;
     for (file = hinf; file; file = file->next)
     {
         if ((section_index = find_section( file, section )) == -1) continue;
@@ -1378,6 +1384,12 @@ BOOL WINAPI SetupGetLineByIndexW( HINF hinf, PCWSTR section, DWORD index, INFCON
     struct inf_file *file = hinf;
     int section_index;
 
     struct inf_file *file = hinf;
     int section_index;
 
+    if (hinf == NULL || hinf == INVALID_HANDLE_VALUE)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
     SetLastError( ERROR_SECTION_NOT_FOUND );
     for (file = hinf; file; file = file->next)
     {
     SetLastError( ERROR_SECTION_NOT_FOUND );
     for (file = hinf; file; file = file->next)
     {
@@ -1438,6 +1450,12 @@ BOOL WINAPI SetupFindFirstLineW( HINF hinf, PCWSTR section, PCWSTR key, INFCONTE
     struct inf_file *file;
     int section_index;
 
     struct inf_file *file;
     int section_index;
 
+    if (hinf == NULL || hinf == INVALID_HANDLE_VALUE)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
     SetLastError( ERROR_SECTION_NOT_FOUND );
     for (file = hinf; file; file = file->next)
     {
     SetLastError( ERROR_SECTION_NOT_FOUND );
     for (file = hinf; file; file = file->next)
     {