diff options
author | tijl <tijl@FreeBSD.org> | 2014-06-20 07:32:03 +0000 |
---|---|---|
committer | tijl <tijl@FreeBSD.org> | 2014-06-20 07:32:03 +0000 |
commit | de4e2206d57bda2268e6b69f09b86ff63cc71f8e (patch) | |
tree | 60af671abf1bc0d1bc97daa15754adcb118b899b /lib/libiconv_modules/HZ | |
parent | 7944ea7242fccf98384460100e2b5e384628fa89 (diff) | |
download | FreeBSD-src-de4e2206d57bda2268e6b69f09b86ff63cc71f8e.zip FreeBSD-src-de4e2206d57bda2268e6b69f09b86ff63cc71f8e.tar.gz |
MFC r267436-267439:
- Replace malloc+memset with calloc.
- iconv_open(3): initialise ci_ilseq_invalid field of _citrus_iconv_shared
struct after allocation with malloc.
- iconvlist(3): reduce a memory leak by copying strings only once.
- iconv(1):
- Make invalids variable local to do_conv such that it prints the number
of invalid characters of the current file instead of an accumulated
value.
- Make do_conv return an error when invalid characters have been found.
Return EXIT_FAILURE from main if any file contained invalid characters.
This matches the behaviour of GNU iconv.
- Mark usage with __dead2 attribute.
- Make the long_options array const.
Tested by: Pavel Timofeev <timp87@gmail.com>
Diffstat (limited to 'lib/libiconv_modules/HZ')
-rw-r--r-- | lib/libiconv_modules/HZ/citrus_hz.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libiconv_modules/HZ/citrus_hz.c b/lib/libiconv_modules/HZ/citrus_hz.c index f9eb006..d772b38 100644 --- a/lib/libiconv_modules/HZ/citrus_hz.c +++ b/lib/libiconv_modules/HZ/citrus_hz.c @@ -532,10 +532,9 @@ _citrus_HZ_parse_graphic(void *context, const char *name, const char *s) p = (void **)context; escape = (escape_t *)p[0]; ei = (_HZEncodingInfo *)p[1]; - graphic = malloc(sizeof(*graphic)); + graphic = calloc(1, sizeof(*graphic)); if (graphic == NULL) return (ENOMEM); - memset(graphic, 0, sizeof(*graphic)); if (strcmp("GL", name) == 0) { if (GL(escape) != NULL) goto release; @@ -598,10 +597,9 @@ _citrus_HZ_parse_escape(void *context, const char *name, const char *s) void *p[2]; ei = (_HZEncodingInfo *)context; - escape = malloc(sizeof(*escape)); + escape = calloc(1, sizeof(*escape)); if (escape == NULL) return (EINVAL); - memset(escape, 0, sizeof(*escape)); if (strcmp("0", name) == 0) { escape->set = E0SET(ei); TAILQ_INSERT_TAIL(E0SET(ei), escape, entry); |