From owner-svn-src-stable@freebsd.org Mon Sep 14 18:52:42 2015 Return-Path: Delivered-To: svn-src-stable@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 C7CB3A046F6; Mon, 14 Sep 2015 18:52:42 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 B84BF1623; Mon, 14 Sep 2015 18:52:42 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8EIqgiB017364; Mon, 14 Sep 2015 18:52:42 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8EIqg8b017363; Mon, 14 Sep 2015 18:52:42 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201509141852.t8EIqg8b017363@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 14 Sep 2015 18:52:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287794 - stable/10/usr.bin/iconv X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2015 18:52:42 -0000 Author: delphij Date: Mon Sep 14 18:52:41 2015 New Revision: 287794 URL: https://svnweb.freebsd.org/changeset/base/287794 Log: MFC r287319: Constify opt_f and opt_t and eliminate unneeded copying. This fixes memory leaks. Reported by: clang static analyzer Modified: stable/10/usr.bin/iconv/iconv.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/iconv/iconv.c ============================================================================== --- stable/10/usr.bin/iconv/iconv.c Mon Sep 14 18:44:13 2015 (r287793) +++ stable/10/usr.bin/iconv/iconv.c Mon Sep 14 18:52:41 2015 (r287794) @@ -156,11 +156,11 @@ int main(int argc, char **argv) { FILE *fp; - char *opt_f, *opt_t; + const char *opt_f, *opt_t; int ch, i, res; bool opt_c = false, opt_s = false; - opt_f = opt_t = strdup(""); + opt_f = opt_t = ""; setlocale(LC_ALL, ""); setprogname(argv[0]); @@ -186,12 +186,12 @@ main(int argc, char **argv) case 'f': /* from */ if (optarg != NULL) - opt_f = strdup(optarg); + opt_f = optarg; break; case 't': /* to */ if (optarg != NULL) - opt_t = strdup(optarg); + opt_t = optarg; break; default: usage();