From: Wez Furlong Date: Mon, 28 Apr 2003 14:41:36 +0000 (+0000) Subject: Fix for #23340; fopen on multiple urls from the same server crashes. X-Git-Tag: SPL_ALPHA~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=169b3f72ed67e5ceafc72fe75b11ce52338b85d1;p=php Fix for #23340; fopen on multiple urls from the same server crashes. --- 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 */