svn commit: r317742 - head/usr.sbin/fdread
Marcelo Araujo
araujo at FreeBSD.org
Wed May 3 13:57:33 UTC 2017
Author: araujo
Date: Wed May 3 13:57:31 2017
New Revision: 317742
URL: https://svnweb.freebsd.org/changeset/base/317742
Log:
Free the memory allocated to trackbuf before exiting, it might fix a potential
memory leak.
Submitted by: trix at juniper.net
MFC after: 2 weeks.
Differential Revision: https://reviews.freebsd.org/D9856
Modified:
head/usr.sbin/fdread/fdread.c
Modified: head/usr.sbin/fdread/fdread.c
==============================================================================
--- head/usr.sbin/fdread/fdread.c Wed May 3 13:47:02 2017 (r317741)
+++ head/usr.sbin/fdread/fdread.c Wed May 3 13:57:31 2017 (r317742)
@@ -184,6 +184,7 @@ doread(int fd, FILE *of, const char *_de
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 *_de
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 *_de
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 *_de
continue;
}
}
+ free(trackbuf);
if (!quiet) {
putc('\n', stderr);
if (nerrs)
More information about the svn-src-head
mailing list