Windows: Check for "calloc" allocation failure.
authorGaurav <g.gupta@samsung.com>
Wed, 13 May 2015 08:21:46 +0000 (13:51 +0530)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 14 May 2015 03:26:57 +0000 (20:26 -0700)
It need to check return value  of calloc. It may fail & return Null.

Closes #67

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_usb.c

index e6a0483..ccff8a1 100644 (file)
@@ -1661,6 +1661,10 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
                                                        LOOP_BREAK(LIBUSB_ERROR_OVERFLOW);
                                                }
                                                if_guid = (GUID*) calloc(1, sizeof(GUID));
+                                               if (if_guid == NULL) {
+                                                       usbi_err(ctx, "could not calloc for if_guid: not enough memory");
+                                                       LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
+                                               }
                                                pCLSIDFromString(guid_string_w, if_guid);
                                                guid[nb_guids++] = if_guid;
                                                usbi_dbg("extra GUID: %s", guid_to_string(if_guid));