[ros-diffs] [hpoussin] 20277: Don't try to dereference possible
NULL pointers
hpoussin at svn.reactos.com
hpoussin at svn.reactos.com
Tue Dec 20 21:08:03 CET 2005
Don't try to dereference possible NULL pointers
Modified: trunk/reactos/lib/setupapi/devinst.c
_____
Modified: trunk/reactos/lib/setupapi/devinst.c
--- trunk/reactos/lib/setupapi/devinst.c 2005-12-20 19:54:25 UTC
(rev 20276)
+++ trunk/reactos/lib/setupapi/devinst.c 2005-12-20 20:07:40 UTC
(rev 20277)
@@ -5311,13 +5311,18 @@
NULL);
/* Copy MatchingId information */
- driverInfo->MatchingId = HeapAlloc(GetProcessHeap(), 0,
(wcslen(MatchingId) + 1) * sizeof(WCHAR));
- if (!driverInfo->MatchingId)
+ if (MatchingId)
{
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- goto cleanup;
+ driverInfo->MatchingId = HeapAlloc(GetProcessHeap(), 0,
(wcslen(MatchingId) + 1) * sizeof(WCHAR));
+ if (!driverInfo->MatchingId)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ RtlCopyMemory(driverInfo->MatchingId, MatchingId,
(wcslen(MatchingId) + 1) * sizeof(WCHAR));
}
- RtlCopyMemory(driverInfo->MatchingId, MatchingId,
(wcslen(MatchingId) + 1) * sizeof(WCHAR));
+ else
+ driverInfo->MatchingId = NULL;
/* Get inf install section */
Result = FALSE;
@@ -6313,10 +6318,12 @@
SetLastError(ERROR_INVALID_USER_BUFFER);
else
{
- struct DeviceInfoElement *devInfo = (struct DeviceInfoElement
*)DeviceInfoData->Reserved;
+ struct DeviceInfoElement *devInfo = NULL;
PLIST_ENTRY ItemList;
+ if (DeviceInfoData)
+ devInfo = (struct DeviceInfoElement
*)DeviceInfoData->Reserved;
if (DriverType == SPDIT_CLASSDRIVER ||
- devInfo->CreationFlags & DICD_INHERIT_CLASSDRVS)
+ (devInfo && devInfo->CreationFlags &
DICD_INHERIT_CLASSDRVS))
{
ListHead = &((struct DeviceInfoSet
*)DeviceInfoSet)->DriverListHead;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.reactos.org/pipermail/ros-diffs/attachments/20051220/3a024d01/attachment.html
More information about the Ros-diffs
mailing list