From: Brendan Cully Date: Tue, 21 Feb 2006 21:52:17 +0000 (+0000) Subject: Preallocate some buffer space before attempting vsnprintf in X-Git-Tag: mutt-1-5-12-rel~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1c3e972a8c6415978e4f8ed0a8ae643e57439f1;p=mutt Preallocate some buffer space before attempting vsnprintf in mutt_buffer_printf (Solaris 9 workaround). --- diff --git a/muttlib.c b/muttlib.c index 1a4eee27..3cca4c0a 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1429,6 +1429,14 @@ int mutt_buffer_printf (BUFFER* buf, const char* fmt, ...) doff = buf->dptr - buf->data; blen = buf->dsize - doff; + /* solaris 9 vsnprintf barfs when blen is 0 */ + if (!blen) + { + blen = 128; + buf->dsize += blen; + safe_realloc (&buf->data, buf->dsize); + buf->dptr = buf->data + doff; + } if ((len = vsnprintf (buf->dptr, blen, fmt, ap)) >= blen) { blen = ++len - blen;