From: Nikita Popov Date: Thu, 4 Sep 2014 19:55:27 +0000 (+0200) Subject: Fix smart_str_append() X-Git-Tag: PRE_PHP7_REMOVALS~122^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c5ac397961136be2f53e4c62f2655e54f20bf71;p=php Fix smart_str_append() Would segfault if src->s == NULL. --- diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h index c153fa884c..8b79e3edbc 100644 --- a/ext/standard/php_smart_str.h +++ b/ext/standard/php_smart_str.h @@ -158,9 +158,11 @@ static inline char *smart_str_print_unsigned(char *buf, zend_long num) { #define smart_str_append_off_t_ex(dest, num, type) \ smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed) -#define smart_str_append_ex(dest, src, what) \ - smart_str_appendl_ex((dest), ((smart_str *)(src))->s->val, \ - ((smart_str *)(src))->s->len, (what)); +#define smart_str_append_ex(dest, src, what) do { \ + if ((src)->s && (src)->s->len) { \ + smart_str_appendl_ex((dest), (src)->s->val, (src)->s->len, (what)); \ + } \ +} while(0) #define smart_str_setl(dest, src, nlen) do { \ smart_str_free((dest)); \