Date: Wed, 17 May 2017 05:28:17 +0000 (UTC) From: Marcelo Araujo <araujo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318395 - stable/11/usr.sbin/fdread Message-ID: <201705170528.v4H5SHRl042942@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: araujo Date: Wed May 17 05:28:16 2017 New Revision: 318395 URL: https://svnweb.freebsd.org/changeset/base/318395 Log: 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 Modified: stable/11/usr.sbin/fdread/fdread.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/fdread/fdread.c ============================================================================== --- stable/11/usr.sbin/fdread/fdread.c Wed May 17 05:21:03 2017 (r318394) +++ stable/11/usr.sbin/fdread/fdread.c Wed May 17 05:28:16 2017 (r318395) @@ -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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705170528.v4H5SHRl042942>