From owner-svn-src-all@freebsd.org Wed May 3 13:57:33 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29D8CD5C6F2; Wed, 3 May 2017 13:57:33 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EFE96F9E; Wed, 3 May 2017 13:57:32 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v43DvWkN084342; Wed, 3 May 2017 13:57:32 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v43DvWDl084341; Wed, 3 May 2017 13:57:32 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201705031357.v43DvWDl084341@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Wed, 3 May 2017 13:57:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317742 - head/usr.sbin/fdread X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 13:57:33 -0000 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)