summaryrefslogtreecommitdiffstats
path: root/usr.sbin/installboot
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2015-11-03 11:38:41 +0000
committerjsg <jsg@openbsd.org>2015-11-03 11:38:41 +0000
commitc4643c3c6afa9aeafb075ba0bfb9d2af2213029c (patch)
tree3c25ca44c70a6332f894a814091704a3bc994e58 /usr.sbin/installboot
parentwe need an unbreakable space in O(log2 n). (diff)
downloadwireguard-openbsd-c4643c3c6afa9aeafb075ba0bfb9d2af2213029c.tar.xz
wireguard-openbsd-c4643c3c6afa9aeafb075ba0bfb9d2af2213029c.zip
fix a memory leak in an error path
Diffstat (limited to 'usr.sbin/installboot')
-rw-r--r--usr.sbin/installboot/i386_installboot.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c
index be0f42c6fc2..6bbf514b59d 100644
--- a/usr.sbin/installboot/i386_installboot.c
+++ b/usr.sbin/installboot/i386_installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i386_installboot.c,v 1.15 2015/10/25 21:21:15 stsp Exp $ */
+/* $OpenBSD: i386_installboot.c,v 1.16 2015/11/03 11:38:41 jsg Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@@ -502,8 +502,10 @@ findgptefisys(int devfd, struct disklabel *dl)
err(1, NULL);
for (i = 0; i < (ghpartnum + ghpartspersec - 1) / ghpartspersec; i++) {
len = pread(devfd, secbuf, dl->d_secsize, off);
- if (len != dl->d_secsize)
+ if (len != dl->d_secsize) {
+ free(secbuf);
return (-1);
+ }
memcpy(gp + i * ghpartspersec, secbuf,
ghpartspersec * sizeof(struct gpt_partition));
off += dl->d_secsize;