Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Dec 2010 15:11:49 +0000 (UTC)
From:      Kevin Lo <kevlo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216431 - head/lib/libusb
Message-ID:  <201012141511.oBEFBnEc021946@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevlo
Date: Tue Dec 14 15:11:49 2010
New Revision: 216431
URL: http://svn.freebsd.org/changeset/base/216431

Log:
  Check the return value of malloc().
  
  Reviewed by:	hselasky
  MFC after:	3 days

Modified:
  head/lib/libusb/libusb20_compat01.c

Modified: head/lib/libusb/libusb20_compat01.c
==============================================================================
--- head/lib/libusb/libusb20_compat01.c	Tue Dec 14 13:45:57 2010	(r216430)
+++ head/lib/libusb/libusb20_compat01.c	Tue Dec 14 15:11:49 2010	(r216431)
@@ -457,6 +457,11 @@ usb_parse_configuration(struct usb_confi
 
 	/* 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012141511.oBEFBnEc021946>