]> granicus.if.org Git - mutt/commitdiff
Preallocate some buffer space before attempting vsnprintf in
authorBrendan Cully <brendan@kublai.com>
Tue, 21 Feb 2006 21:52:17 +0000 (21:52 +0000)
committerBrendan Cully <brendan@kublai.com>
Tue, 21 Feb 2006 21:52:17 +0000 (21:52 +0000)
mutt_buffer_printf (Solaris 9 workaround).

muttlib.c

index 1a4eee27b6b7551928bb8b2f962e375da0e1431d..3cca4c0abfadc482804812b62861468d60b5c7cf 100644 (file)
--- 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;