From: Pierrick Charron Date: Sun, 4 Dec 2011 01:34:54 +0000 (+0000) Subject: Fixed bug #60439curl_copy_handle segfault when used with CURLOPT_PROGRESSFUNCTION X-Git-Tag: php-5.4.0RC3~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=191835fd3d584591f00f83fce1f7f1915198b77c;p=php Fixed bug #60439curl_copy_handle segfault when used with CURLOPT_PROGRESSFUNCTION --- diff --git a/NEWS b/NEWS index 0dde31877f..4056bbb77e 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,10 @@ PHP NEWS - CLI SAPI: . Implement FR #60390 (Missing $_SERVER['SERVER_PORT']). (Pierre) +- cURL: + . Fixed bug #60439 (curl_copy_handle segfault when used with + CURLOPT_PROGRESSFUNCTION). (Pierrick) + - Intl: . Added support for UTS #46. (Gustavo) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 52c4314f1c..d1ddcfe9e6 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1645,11 +1645,18 @@ PHP_FUNCTION(curl_copy_handle) zval_add_ref(&ch->handlers->write_header->func_name); dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name; } + + 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_ERRORBUFFER, dupch->err.str); curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch); curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch); + curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (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!