mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-09-21 15:52:39 +02:00
libc: iconv: zero out cv_shared on allocation
Right now we have to zero-initialize most fields in the varius callers, but this is a little error prone. Simplify it by zeroing it out upon allocation instead, drop the other redundant initialization. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D41546
This commit is contained in:
parent
e2030ca246
commit
939199a2b5
@ -70,8 +70,6 @@ __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);
|
||||
}
|
||||
|
@ -140,14 +140,11 @@ open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci,
|
||||
|
||||
/* initialize iconv handle */
|
||||
len_convname = strlen(convname);
|
||||
ci = malloc(sizeof(*ci) + len_convname + 1);
|
||||
ci = calloc(1, sizeof(*ci) + len_convname + 1);
|
||||
if (!ci) {
|
||||
ret = errno;
|
||||
goto err;
|
||||
}
|
||||
ci->ci_module = NULL;
|
||||
ci->ci_ops = NULL;
|
||||
ci->ci_closure = NULL;
|
||||
ci->ci_convname = (void *)&ci[1];
|
||||
memcpy(ci->ci_convname, convname, len_convname + 1);
|
||||
|
||||
|
@ -75,8 +75,6 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps,
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
handle->cv_shared->ci_discard_ilseq = false;
|
||||
handle->cv_shared->ci_hooks = NULL;
|
||||
cs->srcbuf_len = 0;
|
||||
cs->initialized = true;
|
||||
if (s == NULL)
|
||||
|
@ -78,8 +78,6 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n,
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
handle->cv_shared->ci_discard_ilseq = false;
|
||||
handle->cv_shared->ci_hooks = NULL;
|
||||
cs->srcbuf_len = cs->dstbuf_len = 0;
|
||||
cs->initialized = true;
|
||||
if (s == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user