From: Marcus Boerger Date: Sun, 23 Jun 2002 22:02:35 +0000 (+0000) Subject: -allways terminate buffer X-Git-Tag: php-4.3.0dev_zend2_alpha2~133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd4d8d545040d88f505293a48317c36c5646f0dd;p=php -allways terminate buffer -allow pbuf parameter to be NULL for buffer size calculation --- diff --git a/main/spprintf.c b/main/spprintf.c index 1bda78d1c6..fcef72b564 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -627,7 +627,10 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap cc = xbuf_format_converter(&xbuf, format, ap); if (xbuf.nextb <= xbuf.buf_end) *(xbuf.nextb) = '\0'; - *pbuf = xbuf.buf; + else if (xbuf.size) + xbuf.buf[xbuf.size-1] = '\0'; + if (pbuf) + *pbuf = xbuf.buf; return cc; } }