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.
This commit is contained in:
Tijl Coosemans 2014-06-13 08:36:10 +00:00
parent 3fc3c30a27
commit cdd0ebc93b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=267438

View File

@ -83,6 +83,7 @@ __bsd___iconv_open(const char *out, const char *in, struct _citrus_iconv *handle
}
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 int, const char * const *,
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 int, const char * const *,
if (strcmp(curkey, curitem) == 0) {
continue;
}
names[j++] = strdup(curitem);
names[j++] = curitem;
}
np = (const char * const *)names;
do_one(j, np, data);