Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2014 17:36:12 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266510 - head/usr.bin/mkimg
Message-ID:  <201405211736.s4LHaC5J020974@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Wed May 21 17:36:12 2014
New Revision: 266510
URL: http://svnweb.freebsd.org/changeset/base/266510

Log:
  Fix CID 1215128: Free the allocated buf when image_set_size()
  returns and error and we return from bsd_write().

Modified:
  head/usr.bin/mkimg/bsd.c

Modified: head/usr.bin/mkimg/bsd.c
==============================================================================
--- head/usr.bin/mkimg/bsd.c	Wed May 21 17:34:50 2014	(r266509)
+++ head/usr.bin/mkimg/bsd.c	Wed May 21 17:36:12 2014	(r266510)
@@ -82,8 +82,10 @@ bsd_write(lba_t imgsz, void *bootcode)
 
 	imgsz = ncyls * nheads * nsecs;
 	error = image_set_size(imgsz);
-	if (error)
+	if (error) {
+		free(buf);
 		return (error);
+	}
 
 	d = (void *)(buf + secsz);
 	le32enc(&d->d_magic, DISKMAGIC);



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