From 109346779a5929d7fd18aa0dc28732b51cc49d0a Mon Sep 17 00:00:00 2001 From: Pierrick Charron Date: Sun, 4 Dec 2011 01:34:54 +0000 Subject: [PATCH] Fixed bug #60439curl_copy_handle segfault when used with CURLOPT_PROGRESSFUNCTION --- NEWS | 4 +++ ext/curl/interface.c | 7 ++++++ .../tests/curl_copy_handle_basic_008.phpt | 25 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 ext/curl/tests/curl_copy_handle_basic_008.phpt diff --git a/NEWS b/NEWS index e7fa0f4403..5a45ad76e0 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,10 @@ PHP NEWS - BCmath: . Fixed bug #60377 (bcscale related crashes on 64bits platforms). (shm) +- cURL: + . Fixed bug #60439 (curl_copy_handle segfault when used with + CURLOPT_PROGRESSFUNCTION). (Pierrick) + - Date: . Fixed bug #60373 (Startup errors with log_errors on cause segfault). (Derick) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index af6133e533..8bbe454ed4 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1649,11 +1649,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! -- 2.50.1