Date: Wed, 3 May 2017 13:57:32 +0000 (UTC) From: Marcelo Araujo <araujo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317742 - head/usr.sbin/fdread Message-ID: <201705031357.v43DvWDl084341@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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@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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705031357.v43DvWDl084341>