[ntoskrnl/io]
authorMichael Martin <michael.martin@reactos.org>
Tue, 27 Apr 2010 13:41:37 +0000 (13:41 +0000)
committerMichael Martin <michael.martin@reactos.org>
Tue, 27 Apr 2010 13:41:37 +0000 (13:41 +0000)
- Check for null pointers before attempting to copy or free memory.

svn path=/trunk/; revision=47049

reactos/ntoskrnl/io/iomgr/deviface.c

index 8a8db7a..7d97336 100644 (file)
@@ -884,7 +884,8 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid,
 NextReferenceString:
             ExFreePool(ReferenceBi);
             ReferenceBi = NULL;
 NextReferenceString:
             ExFreePool(ReferenceBi);
             ReferenceBi = NULL;
-            ExFreePool(bip);
+            if (bip)
+                ExFreePool(bip);
             bip = NULL;
             if (ReferenceKey != INVALID_HANDLE_VALUE)
             {
             bip = NULL;
             if (ReferenceKey != INVALID_HANDLE_VALUE)
             {
@@ -921,8 +922,11 @@ NextReferenceString:
             Status = STATUS_INSUFFICIENT_RESOURCES;
             goto cleanup;
         }
             Status = STATUS_INSUFFICIENT_RESOURCES;
             goto cleanup;
         }
-        RtlCopyMemory(NewBuffer, ReturnBuffer.Buffer, ReturnBuffer.Length);
-        ExFreePool(ReturnBuffer.Buffer);
+        if (ReturnBuffer.Buffer)
+        {
+            RtlCopyMemory(NewBuffer, ReturnBuffer.Buffer, ReturnBuffer.Length);
+            ExFreePool(ReturnBuffer.Buffer);
+        }
         ReturnBuffer.Buffer = NewBuffer;
     }
     ReturnBuffer.Buffer[ReturnBuffer.Length / sizeof(WCHAR)] = UNICODE_NULL;
         ReturnBuffer.Buffer = NewBuffer;
     }
     ReturnBuffer.Buffer[ReturnBuffer.Length / sizeof(WCHAR)] = UNICODE_NULL;