svn commit: r287319 - head/usr.bin/iconv
Xin LI
delphij at FreeBSD.org
Mon Aug 31 05:57:27 UTC 2015
Author: delphij
Date: Mon Aug 31 05:57:26 2015
New Revision: 287319
URL: https://svnweb.freebsd.org/changeset/base/287319
Log:
Constify opt_f and opt_t and eliminate unneeded copying. This fixes
memory leaks.
Reported by: clang static analyzer
MFC after: 2 weeks
Modified:
head/usr.bin/iconv/iconv.c
Modified: head/usr.bin/iconv/iconv.c
==============================================================================
--- head/usr.bin/iconv/iconv.c Mon Aug 31 05:03:36 2015 (r287318)
+++ head/usr.bin/iconv/iconv.c Mon Aug 31 05:57:26 2015 (r287319)
@@ -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();
More information about the svn-src-all
mailing list