Mercurial > unleashed > prev-conversion
changeset 18854:a374e248a396
loader: Fix some resource leaks in common/boot.c
illumos issue #9613
author | Toomas Soome <tsoome@me.com> |
---|---|
date | Sat, 16 Jun 2018 15:17:37 +0300 |
parents | 57dc9dd6859f |
children | c104e146d3a9 |
files | usr/src/boot/sys/boot/common/boot.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/boot/sys/boot/common/boot.c Mon Jul 16 16:05:40 2018 +0300 +++ b/usr/src/boot/sys/boot/common/boot.c Sat Jun 16 15:17:37 2018 +0300 @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> * All rights reserved. * @@ -25,7 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); /* * Loading modules, booting the system @@ -307,6 +306,8 @@ goto notfound; /* loop reading lines from /etc/fstab What was that about sscanf again? */ + fstyp = NULL; + dev = NULL; while (fgetstr(lbuf, sizeof(lbuf), fd) >= 0) { if ((lbuf[0] == 0) || (lbuf[0] == '#')) continue; @@ -318,6 +319,7 @@ continue; /* delimit and save */ *cp++ = 0; + free(dev); dev = strdup(lbuf); /* skip whitespace up to mountpoint */ @@ -337,6 +339,7 @@ while ((*cp != 0) && !isspace(*cp)) cp++; *cp = 0; + free(fstyp); fstyp = strdup(ep); /* skip whitespace up to mount options */ @@ -353,8 +356,6 @@ options = strdup(ep); /* Build the <fstype>:<device> and save it in vfs.root.mountfrom */ sprintf(lbuf, "%s:%s", fstyp, dev); - free(dev); - free(fstyp); setenv("vfs.root.mountfrom", lbuf, 0); /* Don't override vfs.root.mountfrom.options if it is already set */ @@ -367,6 +368,8 @@ break; } close(fd); + free(dev); + free(fstyp); notfound: if (error) { @@ -378,6 +381,7 @@ cp[strlen(cp) - 1] = '\0'; setenv("vfs.root.mountfrom", cp, 0); error = 0; + free(cp); } }