summaryrefslogtreecommitdiffstats
path: root/lib/libc/iconv/citrus_iconv.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2013-05-25 12:11:20 +0000
committered <ed@FreeBSD.org>2013-05-25 12:11:20 +0000
commit3f589c4a65061002236515a5e50d5eafb6c1f50f (patch)
treeb6a6a45af9327825d9d6ad49d93b139fbec4d870 /lib/libc/iconv/citrus_iconv.c
parent987739080987bee39127ec6c8175ca15e60a57d9 (diff)
downloadFreeBSD-src-3f589c4a65061002236515a5e50d5eafb6c1f50f.zip
FreeBSD-src-3f589c4a65061002236515a5e50d5eafb6c1f50f.tar.gz
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().
Diffstat (limited to 'lib/libc/iconv/citrus_iconv.c')
-rw-r--r--lib/libc/iconv/citrus_iconv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c
index 941ee02..04acccf 100644
--- a/lib/libc/iconv/citrus_iconv.c
+++ b/lib/libc/iconv/citrus_iconv.c
@@ -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 * __restrict * __restrict rcv,
ret = (*ci->ci_ops->io_init_context)(*rcv);
if (ret) {
release_shared(ci);
- free(*rcv);
+ free(cv);
return (ret);
}
return (0);
OpenPOWER on IntegriCloud