svn commit: r216751 - stable/8/lib/libusb

Kevin Lo kevlo at FreeBSD.org
Tue Dec 28 02:43:29 UTC 2010


Author: kevlo
Date: Tue Dec 28 02:43:28 2010
New Revision: 216751
URL: http://svn.freebsd.org/changeset/base/216751

Log:
  MFC r216431:
  Check return value of malloc().
  
  Reviewed by:	hselasky

Modified:
  stable/8/lib/libusb/libusb20_compat01.c

Modified: stable/8/lib/libusb/libusb20_compat01.c
==============================================================================
--- stable/8/lib/libusb/libusb20_compat01.c	Tue Dec 28 02:25:32 2010	(r216750)
+++ stable/8/lib/libusb/libusb20_compat01.c	Tue Dec 28 02:43:28 2010	(r216751)
@@ -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);


More information about the svn-src-all mailing list