summaryrefslogtreecommitdiff
path: root/main/spprintf.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-06-23 22:02:35 +0000
committerMarcus Boerger <helly@php.net>2002-06-23 22:02:35 +0000
commitfd4d8d545040d88f505293a48317c36c5646f0dd (patch)
tree3b058646e0100b75bc8c6b57dd626ea8f7c384ed /main/spprintf.c
parent372cab27ad24790598226d54ee2e6c6ff4598792 (diff)
downloadphp-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.c5
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;
}
}