From: Jaroslav Kysela Date: Fri, 29 May 2015 18:41:11 +0000 (+0200) Subject: intlconv_utf8safestr: do not return NULL but empty string when max_size is zero X-Git-Tag: v4.2.1~2419 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63d4ae0116b5deb3d48147c40b09c1c13cac2e37;p=thirdparty%2Ftvheadend.git intlconv_utf8safestr: do not return NULL but empty string when max_size is zero --- diff --git a/src/intlconv.c b/src/intlconv.c index eebee7692..0856ab7ed 100644 --- a/src/intlconv.c +++ b/src/intlconv.c @@ -166,9 +166,15 @@ intlconv_utf8safestr( const char *dst_charset_id, const char *src_utf8, size_t max_size ) { - char *str = alloca(max_size), *res; - ssize_t r = intlconv_utf8(str, max_size, dst_charset_id, src_utf8); + char *str, *res; + ssize_t r; size_t i; + + if (max_size == 0 || *src_utf8 == '\0') + return strdup(""); + + str = alloca(max_size); + r = intlconv_utf8(str, max_size, dst_charset_id, src_utf8); if (r <= 0) return NULL; if (r >= max_size)