diff options
| author | Nikita Popov <nikic@php.net> | 2014-09-04 21:55:27 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2014-09-04 21:55:27 +0200 |
| commit | 0c5ac397961136be2f53e4c62f2655e54f20bf71 (patch) | |
| tree | b4c8600118504f57353c4a0406cd10caf2b8af48 | |
| parent | 00805ffb92077bb51d83ad7d0475a501589a7f21 (diff) | |
| download | php-git-0c5ac397961136be2f53e4c62f2655e54f20bf71.tar.gz | |
Fix smart_str_append()
Would segfault if src->s == NULL.
| -rw-r--r-- | ext/standard/php_smart_str.h | 8 |
1 files changed, 5 insertions, 3 deletions
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)); \ |
