diff options
| author | Wez Furlong <wez@php.net> | 2003-04-28 14:41:36 +0000 | 
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2003-04-28 14:41:36 +0000 | 
| commit | 169b3f72ed67e5ceafc72fe75b11ce52338b85d1 (patch) | |
| tree | 82f7929af593cbd8b98d746f5fa02991bd4286ad | |
| parent | 810ac117f0322d0c7954194462d890cdee915446 (diff) | |
| download | php-git-169b3f72ed67e5ceafc72fe75b11ce52338b85d1.tar.gz | |
Fix for #23340; fopen on multiple urls from the same server crashes.
| -rw-r--r-- | ext/standard/http_fopen_wrapper.c | 13 | 
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index ab3bc5b11f..0e53489d1b 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -305,14 +305,21 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,  	location[0] = '\0'; +	if (!header_init && FAILURE == zend_hash_find(EG(active_symbol_table), +				"http_response_header", sizeof("http_response_header"), (void **) &response_header)) { +		header_init = 1; +	} +  	if (header_init) {  		zval *tmp;  		MAKE_STD_ZVAL(tmp);  		array_init(tmp);  		ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", tmp); +	 +		zend_hash_find(EG(active_symbol_table), +				"http_response_header", sizeof("http_response_header"), (void **) &response_header);  	} -	zend_hash_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header"), (void **) &response_header);  	if (!php_stream_eof(stream))	{  		/* get response header */ @@ -322,6 +329,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,  			int response_code;  			MAKE_STD_ZVAL(http_response); +			ZVAL_NULL(http_response); +  			response_code = atoi(tmp_line + 9);  			switch(response_code) {  				case 200: @@ -365,6 +374,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,  			int http_header_line_length;  			http_header_line[HTTP_HEADER_BLOCK_SIZE-1] = '\0'; +  			p = http_header_line;  			while(*p) {  				while(*p == '\n' || *p == '\r')	{ @@ -478,6 +488,7 @@ out:  	if (stream) {  		if (header_init) {  			stream->wrapperdata = *response_header; +			zval_add_ref(response_header);  		}  		php_stream_notify_progress_init(context, 0, file_size);  		/* Restore original chunk size now that we're done with headers */  | 
