Date: Sat, 25 May 2013 12:11:21 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250980 - head/lib/libc/iconv Message-ID: <201305251211.r4PCBLWb006156@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305251211.r4PCBLWb006156>