Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jun 2014 08:36:10 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267438 - head/lib/libc/iconv
Message-ID:  <201406130836.s5D8aAnQ075628@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tijl
Date: Fri Jun 13 08:36:10 2014
New Revision: 267438
URL: http://svnweb.freebsd.org/changeset/base/267438

Log:
  iconv_open: initialise ci_ilseq_invalid field of _citrus_iconv_shared
  struct after allocation with malloc.
  
  iconvlist: reduce a memory leak by copying strings only once.

Modified:
  head/lib/libc/iconv/bsd_iconv.c

Modified: head/lib/libc/iconv/bsd_iconv.c
==============================================================================
--- head/lib/libc/iconv/bsd_iconv.c	Fri Jun 13 08:28:51 2014	(r267437)
+++ head/lib/libc/iconv/bsd_iconv.c	Fri Jun 13 08:36:10 2014	(r267438)
@@ -83,6 +83,7 @@ __bsd___iconv_open(const char *out, cons
 	}
 
 	handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE");
+	handle->cv_shared->ci_ilseq_invalid = false;
 	handle->cv_shared->ci_hooks = NULL;
 
 	return ((iconv_t)(void *)handle);
@@ -223,7 +224,7 @@ __bsd_iconvlist(int (*do_one) (unsigned 
 			return;
 		}
 		strlcpy(curkey, list[i], slashpos - list[i] + 1);
-		names[j++] = strdup(curkey);
+		names[j++] = curkey;
 		for (; (i < sz) && (memcmp(curkey, list[i], strlen(curkey)) == 0); i++) {
 			slashpos = strchr(list[i], '/');
 			curitem = (char *)malloc(strlen(slashpos) + 1);
@@ -235,7 +236,7 @@ __bsd_iconvlist(int (*do_one) (unsigned 
 			if (strcmp(curkey, curitem) == 0) {
 				continue;
 			}
-			names[j++] = strdup(curitem);
+			names[j++] = curitem;
 		}
 		np = (const char * const *)names;
 		do_one(j, np, data);



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