diff options
author | Marcus Boerger <helly@php.net> | 2002-06-23 22:02:35 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2002-06-23 22:02:35 +0000 |
commit | fd4d8d545040d88f505293a48317c36c5646f0dd (patch) | |
tree | 3b058646e0100b75bc8c6b57dd626ea8f7c384ed /main/spprintf.c | |
parent | 372cab27ad24790598226d54ee2e6c6ff4598792 (diff) | |
download | php-git-fd4d8d545040d88f505293a48317c36c5646f0dd.tar.gz |
-allways terminate buffer
-allow pbuf parameter to be NULL for buffer size calculation
Diffstat (limited to 'main/spprintf.c')
-rw-r--r-- | main/spprintf.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } } |