+2007-11-03 Bruno Haible <bruno@clisp.org>
+
+ * lib/vasnprintf.c (VASNPRINTF): Don't assume that snprintf's return
+ value is C99 compliant.
+ Needed for OSF/1 5.1.
+
2007-11-03 Bruno Haible <bruno@clisp.org>
Fix out-of-memory handling of vasnprintf.
}
#if USE_SNPRINTF
- /* Handle overflow of the allocated buffer. */
- if (count >= maxlen)
+ /* Handle overflow of the allocated buffer.
+ If such an overflow occurs, a C99 compliant snprintf()
+ returns a count >= maxlen. However, a non-compliant
+ snprintf() function returns only count = maxlen - 1. To
+ cover both cases, test whether count >= maxlen - 1. */
+ if ((unsigned int) count + 1 >= maxlen)
{
/* If maxlen already has attained its allowed maximum,
allocating more memory will not increase maxlen.