From owner-svn-src-head@freebsd.org Sat Mar 4 20:46:58 2017 Return-Path: Delivered-To: svn-src-head@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 C60FACF92DF; Sat, 4 Mar 2017 20:46:58 +0000 (UTC) (envelope-from cem@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 95F3F1EE2; Sat, 4 Mar 2017 20:46:58 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24KkvQQ062505; Sat, 4 Mar 2017 20:46:57 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24KkvTw062504; Sat, 4 Mar 2017 20:46:57 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201703042046.v24KkvTw062504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sat, 4 Mar 2017 20:46:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314677 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 20:46:58 -0000 Author: cem Date: Sat Mar 4 20:46:57 2017 New Revision: 314677 URL: https://svnweb.freebsd.org/changeset/base/314677 Log: fts: Fix a potential memory leak in error case Dan Krejsa reports a potential memory leak in an fts_build error case, detected by Coverity. (It doesn't seem to show up in Coverity Scan, so I don't have a CID to point to.) I don't know whether it is actually possible to arrive in this case with a non-empty 'head' list. The cost is low, though. One additional branch in a terminal error case isn't the end of the world. PR: 217125 Submitted by: Dan Krejsa Modified: head/lib/libc/gen/fts.c Modified: head/lib/libc/gen/fts.c ============================================================================== --- head/lib/libc/gen/fts.c Sat Mar 4 20:35:34 2017 (r314676) +++ head/lib/libc/gen/fts.c Sat Mar 4 20:46:57 2017 (r314677) @@ -850,6 +850,7 @@ mem1: saved_errno = errno; (cur->fts_level == FTS_ROOTLEVEL ? FCHDIR(sp, sp->fts_rfd) : fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { + fts_lfree(head); cur->fts_info = FTS_ERR; SET(FTS_STOP); return (NULL);