mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Guarantee that iconvert() never returns NULL. This is a clumsy, but effective
way to prevent NULL dereferences after the recent character conversion changes in other parts of ezstream. git-svn-id: https://svn.xiph.org/trunk/ezstream@15778 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
10d883fa98
commit
2e33855113
16
src/util.c
16
src/util.c
@ -248,9 +248,6 @@ CHARtoUTF8(const char *in_str, int mode)
|
||||
snprintf(codeset, sizeof(codeset), "CP%u", GetACP());
|
||||
#endif /* !WIN32 */
|
||||
|
||||
if (in_str == NULL || strlen(in_str) == 0)
|
||||
return (NULL);
|
||||
|
||||
return (iconvert(in_str, codeset, "UTF-8", mode));
|
||||
}
|
||||
|
||||
@ -273,9 +270,6 @@ UTF8toCHAR(const char *in_str, int mode)
|
||||
snprintf(codeset, sizeof(codeset), "CP%u", GetACP());
|
||||
#endif /* !WIN32 */
|
||||
|
||||
if (in_str == NULL || strlen(in_str) == 0)
|
||||
return (NULL);
|
||||
|
||||
return (iconvert(in_str, "UTF-8", codeset, mode));
|
||||
}
|
||||
|
||||
@ -293,6 +287,9 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
size_t out_pos;
|
||||
char *tocode;
|
||||
|
||||
if (NULL == in_str)
|
||||
return (xstrdup(""));
|
||||
|
||||
switch (mode) {
|
||||
size_t siz;
|
||||
|
||||
@ -318,7 +315,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
(cd = iconv_open(tocode, "")) == (iconv_t)-1) {
|
||||
xfree(tocode);
|
||||
printf("%s: iconv_open(): %s\n", __progname, strerror(errno));
|
||||
return (NULL);
|
||||
return (xstrdup(in_str));
|
||||
}
|
||||
|
||||
ip = input = (ICONV_CONST char *)in_str;
|
||||
@ -359,7 +356,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
printf("%s: iconv_close(): %s\n", __progname, strerror(errno));
|
||||
xfree(output);
|
||||
xfree(tocode);
|
||||
return (NULL);
|
||||
return (xstrdup(in_str));
|
||||
}
|
||||
|
||||
xfree(tocode);
|
||||
@ -369,6 +366,9 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
(void)to;
|
||||
(void)mode;
|
||||
|
||||
if (NULL == in_str)
|
||||
return (xstrdup(""));
|
||||
|
||||
return (xstrdup(in_str));
|
||||
#endif /* HAVE_ICONV */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user