From c4643c3c6afa9aeafb075ba0bfb9d2af2213029c Mon Sep 17 00:00:00 2001 From: jsg Date: Tue, 3 Nov 2015 11:38:41 +0000 Subject: fix a memory leak in an error path --- usr.sbin/installboot/i386_installboot.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.sbin/installboot') 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; -- cgit v1.2.3-59-g8ed1b