From: Bruno Haible Date: Sat, 10 Apr 2010 20:17:02 +0000 (+0200) Subject: vasnprintf: Fix crash in %ls directive. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d1664e8e930d8fa6a29db4caac4d21623e42c8;p=pspp vasnprintf: Fix crash in %ls directive. --- diff --git a/ChangeLog b/ChangeLog index de6afa4281..7b6570d42b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 794fb85f81..f0144a2b12 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;