From 9998d4b63fa09790aeb903c5a6817ce8792810ba Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Tue, 14 Dec 2010 15:11:49 +0000 Subject: [PATCH] Check the return value of malloc(). Reviewed by: hselasky MFC after: 3 days --- lib/libusb/libusb20_compat01.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/libusb/libusb20_compat01.c b/lib/libusb/libusb20_compat01.c index aaafb02cb11..4124ef6fbcd 100644 --- a/lib/libusb/libusb20_compat01.c +++ b/lib/libusb/libusb20_compat01.c @@ -457,6 +457,11 @@ usb_parse_configuration(struct usb_config_descriptor *config, /* allocate memory for our configuration */ ptr = malloc(a + b + c + d); + if (ptr == NULL) { + /* free config structure */ + free(ps.a.currcfg); + return (-1); + } /* "currifcw" must be first, hence this pointer is freed */ ps.b.currifcw = (void *)(ptr);