From owner-svn-src-all@FreeBSD.ORG Sat May 25 12:11:21 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A166113C; Sat, 25 May 2013 12:11:21 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9411DEEE; Sat, 25 May 2013 12:11:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4PCBLl6006157; Sat, 25 May 2013 12:11:21 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4PCBLWb006156; Sat, 25 May 2013 12:11:21 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201305251211.r4PCBLWb006156@svn.freebsd.org> From: Ed Schouten Date: Sat, 25 May 2013 12:11:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250980 - 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-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 May 2013 12:11:21 -0000 Author: ed Date: Sat May 25 12:11:20 2013 New Revision: 250980 URL: http://svnweb.freebsd.org/changeset/base/250980 Log: Only call free() on something we allocated. If we were already provided a struct _citrus_iconv (e.g. through iconv_open_into()), we should not call free() in case io_init_context() fails. Instead, call it on the pointer of the allocated object, which will be NULL in case of iconv_open_into(). Modified: head/lib/libc/iconv/citrus_iconv.c Modified: head/lib/libc/iconv/citrus_iconv.c ============================================================================== --- head/lib/libc/iconv/citrus_iconv.c Sat May 25 11:42:25 2013 (r250979) +++ head/lib/libc/iconv/citrus_iconv.c Sat May 25 12:11:20 2013 (r250980) @@ -258,7 +258,7 @@ int _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, const char * __restrict src, const char * __restrict dst) { - struct _citrus_iconv *cv; + struct _citrus_iconv *cv = NULL; struct _citrus_iconv_shared *ci = NULL; char realdst[PATH_MAX], realsrc[PATH_MAX]; char buf[PATH_MAX], path[PATH_MAX]; @@ -301,7 +301,7 @@ _citrus_iconv_open(struct _citrus_iconv ret = (*ci->ci_ops->io_init_context)(*rcv); if (ret) { release_shared(ci); - free(*rcv); + free(cv); return (ret); } return (0);