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().
This commit is contained in:
parent
ffca5883e8
commit
907b803190
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250980
@ -258,7 +258,7 @@ int
|
|||||||
_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
|
_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
|
||||||
const char * __restrict src, const char * __restrict dst)
|
const char * __restrict src, const char * __restrict dst)
|
||||||
{
|
{
|
||||||
struct _citrus_iconv *cv;
|
struct _citrus_iconv *cv = NULL;
|
||||||
struct _citrus_iconv_shared *ci = NULL;
|
struct _citrus_iconv_shared *ci = NULL;
|
||||||
char realdst[PATH_MAX], realsrc[PATH_MAX];
|
char realdst[PATH_MAX], realsrc[PATH_MAX];
|
||||||
char buf[PATH_MAX], path[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);
|
ret = (*ci->ci_ops->io_init_context)(*rcv);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
release_shared(ci);
|
release_shared(ci);
|
||||||
free(*rcv);
|
free(cv);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user