Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
intlconv_utf8safestr: do not return NULL but empty string when max_si…
…ze is zero
  • Loading branch information
perexg committed May 29, 2015
1 parent 807b9c8 commit 63d4ae0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/intlconv.c
Expand Up @@ -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)
Expand Down

0 comments on commit 63d4ae0

Please sign in to comment.