From c725e3ef7addcf817f2a580b0295b16ea893101e Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Mon, 28 Nov 2011 05:34:16 +0000 Subject: [PATCH] Plug memory leaks and fix open(2) error check. Reviewed by: nwhitehorn MFC after: 3 days --- usr.sbin/bsdinstall/distextract/distextract.c | 1 + usr.sbin/bsdinstall/distfetch/distfetch.c | 1 + usr.sbin/bsdinstall/partedit/gpart_ops.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c index 397932f24ccb..a76ebfe64589 100644 --- a/usr.sbin/bsdinstall/distextract/distextract.c +++ b/usr.sbin/bsdinstall/distextract/distextract.c @@ -49,6 +49,7 @@ main(void) dists = calloc(ndists, sizeof(const char *)); if (dists == NULL) { fprintf(stderr, "Out of memory!\n"); + free(diststring); return (1); } diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c index 0ced75cd7beb..bb72417bfac6 100644 --- a/usr.sbin/bsdinstall/distfetch/distfetch.c +++ b/usr.sbin/bsdinstall/distfetch/distfetch.c @@ -48,6 +48,7 @@ main(void) urls = calloc(ndists, sizeof(const char *)); if (urls == NULL) { fprintf(stderr, "Out of memory!\n"); + free(diststring); return (1); } diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 52f145eecaeb..6bbce1720489 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -301,7 +301,7 @@ gpart_bootcode(struct ggeom *gp) return; bootfd = open(bootcode, O_RDONLY); - if (bootfd <= 0) { + if (bootfd < 0) { dialog_msgbox("Bootcode Error", strerror(errno), 0, 0, TRUE); return;