# HG changeset patch # User Bruno Haible # Date 1270930622 -7200 # Node ID 2f3ddf3c58a5c4bb2685c4e8c66a6cf624172c1c # Parent 5faa02e0b2925be1f8e57652f97b471039856860 vasnprintf: Fix crash in %ls directive. diff --git a/ChangeLog b/ChangeLog --- 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 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -2605,8 +2605,16 @@ 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;