From owner-svn-src-all@freebsd.org Wed Dec 6 21:18:46 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 AD2AFE8C573; Wed, 6 Dec 2017 21:18:46 +0000 (UTC) (envelope-from stevek@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 7A350341B; Wed, 6 Dec 2017 21:18:46 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB6LIjRJ019390; Wed, 6 Dec 2017 21:18:45 GMT (envelope-from stevek@FreeBSD.org) Received: (from stevek@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB6LIjgL019389; Wed, 6 Dec 2017 21:18:45 GMT (envelope-from stevek@FreeBSD.org) Message-Id: <201712062118.vB6LIjgL019389@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: stevek set sender to stevek@FreeBSD.org using -f From: "Stephen J. Kiernan" Date: Wed, 6 Dec 2017 21:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326636 - head/contrib/binutils/libiberty X-SVN-Group: head X-SVN-Commit-Author: stevek X-SVN-Commit-Paths: head/contrib/binutils/libiberty X-SVN-Commit-Revision: 326636 X-SVN-Commit-Repository: base 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.25 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, 06 Dec 2017 21:18:46 -0000 Author: stevek Date: Wed Dec 6 21:18:45 2017 New Revision: 326636 URL: https://svnweb.freebsd.org/changeset/base/326636 Log: The function make_relative_prefix_1 does not properly free locally allocated memory when it returns early. Free the memory associated with the variables full_programe, bin_dirs, prog_dirs, and prefix_dirs when the function returns early. Submitted by: Tom Rix Reviewed by: jhibbits, emaste Approved by: sjg (mentor) Obtained from: Juniper Networks, Inc. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D9691 Modified: head/contrib/binutils/libiberty/make-relative-prefix.c Modified: head/contrib/binutils/libiberty/make-relative-prefix.c ============================================================================== --- head/contrib/binutils/libiberty/make-relative-prefix.c Wed Dec 6 21:12:24 2017 (r326635) +++ head/contrib/binutils/libiberty/make-relative-prefix.c Wed Dec 6 21:18:45 2017 (r326636) @@ -299,10 +299,18 @@ make_relative_prefix_1 (const char *progname, const ch full_progname = strdup(progname); prog_dirs = split_directories (full_progname, &prog_num); - bin_dirs = split_directories (bin_prefix, &bin_num); + if (prog_dirs == NULL) + { + free (full_progname); + return NULL; + } free (full_progname); - if (bin_dirs == NULL || prog_dirs == NULL) - return NULL; + bin_dirs = split_directories (bin_prefix, &bin_num); + if (bin_dirs == NULL) + { + free_split_directories(prog_dirs); + return NULL; + } /* Remove the program name from comparison of directory names. */ prog_num--; @@ -365,7 +373,12 @@ make_relative_prefix_1 (const char *progname, const ch ret = (char *) malloc (needed_len); if (ret == NULL) - return NULL; + { + free_split_directories (prog_dirs); + free_split_directories (bin_dirs); + free_split_directories (prefix_dirs); + return NULL; + } /* Build up the pathnames in argv[0]. */ *ret = '\0';