From: Bruno Haible Date: Sat, 10 Apr 2010 20:17:02 +0000 (+0200) Subject: vasnprintf: Fix crash in %ls directive. X-Git-Tag: v0.1~4289 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=32d1664e8e930d8fa6a29db4caac4d21623e42c8;p=gnulib.git vasnprintf: Fix crash in %ls directive. --- diff --git a/ChangeLog b/ChangeLog index de6afa428..7b6570d42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-04-10 Bruno Haible + vasnprintf: Fix crash in %ls directive. + * lib/vasnprintf.c (VASNPRINTF): Don't abort when a unconvertible wide + string is passed as argument to %ls, with no precision and no width. + Reported by Jarno Rajahalme . + +2010-04-10 Bruno Haible + vasnprintf: Fix multiple test failures on mingw. * lib/vasnprintf.c (SNPRINTF) [mingw]: Define to snprintf, not _snprintf, or snwprintf, not _snwprintf. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 794fb85f8..f0144a2b1 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -2605,8 +2605,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, count = wctomb (cbuf, *arg); # endif if (count <= 0) - /* Inconsistency. */ - abort (); + { + /* Cannot convert. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } ENSURE_ALLOCATION (xsum (length, count)); memcpy (result + length, cbuf, count); length += count;