From owner-svn-src-head@FreeBSD.ORG Fri Jun 13 08:36:10 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9EEBF964; Fri, 13 Jun 2014 08:36:10 +0000 (UTC) Received: from svn.freebsd.org (svn.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 8CC1B2075; Fri, 13 Jun 2014 08:36:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5D8aA2w075629; Fri, 13 Jun 2014 08:36:10 GMT (envelope-from tijl@svn.freebsd.org) Received: (from tijl@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5D8aAnQ075628; Fri, 13 Jun 2014 08:36:10 GMT (envelope-from tijl@svn.freebsd.org) Message-Id: <201406130836.s5D8aAnQ075628@svn.freebsd.org> From: Tijl Coosemans Date: Fri, 13 Jun 2014 08:36:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267438 - head/lib/libc/iconv X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jun 2014 08:36:10 -0000 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);