summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraraujo <araujo@FreeBSD.org>2017-05-17 05:28:16 +0000
committeraraujo <araujo@FreeBSD.org>2017-05-17 05:28:16 +0000
commit847ad7b631e1bb90fa11051182061bdce396c755 (patch)
tree5a46606f396f4018d4df8040200f7eb9af108574
parent654221cf4ba7456c568d9e2ea7e42797a8a8ee16 (diff)
downloadFreeBSD-src-847ad7b631e1bb90fa11051182061bdce396c755.zip
FreeBSD-src-847ad7b631e1bb90fa11051182061bdce396c755.tar.gz
MFC r317742:
Free the memory allocated to trackbuf before exiting, it might fix a potential memory leak. Submitted by: trix@juniper.net Differential Revision: https://reviews.freebsd.org/D9856
-rw-r--r--usr.sbin/fdread/fdread.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.sbin/fdread/fdread.c b/usr.sbin/fdread/fdread.c
index f3c2d91..a0cdd85 100644
--- a/usr.sbin/fdread/fdread.c
+++ b/usr.sbin/fdread/fdread.c
@@ -184,6 +184,7 @@ doread(int fd, FILE *of, const char *_devname)
if (rv == 0) {
/* EOF? */
warnx("premature EOF after %u bytes", nbytes);
+ free(trackbuf);
return (EX_OK);
}
if ((unsigned)rv == tracksize) {
@@ -215,6 +216,7 @@ doread(int fd, FILE *of, const char *_devname)
if (!quiet)
putc('\n', stderr);
perror("non-IO error");
+ free(trackbuf);
return (EX_OSERR);
}
if (ioctl(fd, FD_GSTAT, &fdcs) == -1)
@@ -233,6 +235,7 @@ doread(int fd, FILE *of, const char *_devname)
if (!recover) {
if (!quiet)
putc('\n', stderr);
+ free(trackbuf);
return (EX_IOERR);
}
memset(trackbuf, fillbyte, secsize);
@@ -284,6 +287,7 @@ doread(int fd, FILE *of, const char *_devname)
continue;
}
}
+ free(trackbuf);
if (!quiet) {
putc('\n', stderr);
if (nerrs)
OpenPOWER on IntegriCloud