summaryrefslogtreecommitdiffstats
path: root/usr.bin/mkimg
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-05-21 17:36:12 +0000
committermarcel <marcel@FreeBSD.org>2014-05-21 17:36:12 +0000
commit65627bf1cbe652f4e8bd9f5093dfd8e78fe4c3fb (patch)
tree5051a4a1df6f05823694918b8fa9d9363bb2948f /usr.bin/mkimg
parentb00f7d7c651114b3fac6a1cf674ddf0004aa2f83 (diff)
downloadFreeBSD-src-65627bf1cbe652f4e8bd9f5093dfd8e78fe4c3fb.zip
FreeBSD-src-65627bf1cbe652f4e8bd9f5093dfd8e78fe4c3fb.tar.gz
Fix CID 1215128: Free the allocated buf when image_set_size()
returns and error and we return from bsd_write().
Diffstat (limited to 'usr.bin/mkimg')
-rw-r--r--usr.bin/mkimg/bsd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/mkimg/bsd.c b/usr.bin/mkimg/bsd.c
index 52c91f6..a93ed0d 100644
--- a/usr.bin/mkimg/bsd.c
+++ b/usr.bin/mkimg/bsd.c
@@ -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);
OpenPOWER on IntegriCloud