From ef4896d95659af261369bfa2e3c3f2c0317a83e8 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Tue, 20 Jan 2015 11:46:10 -0800 Subject: [PATCH] add protection against nulls --- main/spprintf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main/spprintf.c b/main/spprintf.c index 5b16d514412..01d80b7548f 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -796,6 +796,11 @@ PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap { smart_str xbuf = {0}; + /* since there are places where (v)spprintf called without checking for null, + a bit of defensive coding here */ + if(!pbuf) { + return 0; + } xbuf_format_converter(&xbuf, format, ap); if (max_len && xbuf.len > max_len) {