From: Antony Dovgal Date: Tue, 4 Aug 2009 09:24:48 +0000 (+0000) Subject: fix memleak and possible segfault in HTTP fopen wrapper X-Git-Tag: php-5.4.0alpha1~191^2~2860 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9618b85b65dbd7ae8e0dfb0def23f70a5dcd8054;p=php fix memleak and possible segfault in HTTP fopen wrapper --- diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 840011edb6..ed9185a520 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -391,7 +391,10 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, } smart_str_0(&tmpstr); /* Remove newlines and spaces from start and end. there's at least one extra \r\n at the end that needs to go. */ - tmp = php_trim(tmpstr.c, strlen(tmpstr.c), NULL, 0, NULL, 3 TSRMLS_CC); + if (tmpstr.c) { + tmp = php_trim(tmpstr.c, strlen(tmpstr.c), NULL, 0, NULL, 3 TSRMLS_CC); + smart_str_free(&tmpstr); + } } if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) { /* Remove newlines and spaces from start and end php_trim will estrndup() */