From: Pierrick Charron Date: Sun, 4 Dec 2011 01:16:17 +0000 (+0000) Subject: Fix segfault when using curl_copy_handle with CURLOPT_PROGRESSFUNCTION X-Git-Tag: php-5.5.0alpha1~778 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d84e1b50c6a83d33201552029b01a5b4332d3227;p=php Fix segfault when using curl_copy_handle with CURLOPT_PROGRESSFUNCTION --- diff --git a/ext/curl/interface.c b/ext/curl/interface.c index c2a6f6da98..6eb1fa94c2 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1965,6 +1965,26 @@ PHP_FUNCTION(curl_copy_handle) curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); + if (ch->handlers->progress) { + dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); + if (ch->handlers->progress->func_name) { + zval_add_ref(&ch->handlers->progress->func_name); + dupch->handlers->progress->func_name = ch->handlers->progress->func_name; + } + dupch->handlers->progress->method = ch->handlers->progress->method; + curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch); + } + + if (ch->handlers->fnmatch) { + dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch)); + if (ch->handlers->fnmatch->func_name) { + zval_add_ref(&ch->handlers->fnmatch->func_name); + dupch->handlers->fnmatch->func_name = ch->handlers->fnmatch->func_name; + } + dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method; + curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch); + } + efree(dupch->to_free); dupch->to_free = ch->to_free; diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt new file mode 100644 index 0000000000..692c2df192 --- /dev/null +++ b/ext/curl/tests/curl_copy_handle_basic_008.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Hello World! +Hello World! +Hello World! +Hello World!