Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Sep 2015 18:52:42 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
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
Message-ID:  <201509141852.t8EIqg8b017363@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509141852.t8EIqg8b017363>