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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to