mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
Fixed bug #60439curl_copy_handle segfault when used with CURLOPT_PROGRESSFUNCTION
This commit is contained in:
parent
3fe47ef089
commit
109346779a
3 changed files with 36 additions and 0 deletions
4
NEWS
4
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
25
ext/curl/tests/curl_copy_handle_basic_008.phpt
Normal file
25
ext/curl/tests/curl_copy_handle_basic_008.phpt
Normal file
|
@ -0,0 +1,25 @@
|
|||
--TEST--
|
||||
Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
|
||||
|
||||
$url = "{$host}/get.php";
|
||||
$ch = curl_init($url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function() { });
|
||||
$ch2 = curl_copy_handle($ch);
|
||||
echo curl_exec($ch), PHP_EOL;
|
||||
unset($ch);
|
||||
echo curl_exec($ch2);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Hello World!
|
||||
Hello World!
|
||||
Hello World!
|
||||
Hello World!
|
Loading…
Add table
Add a link
Reference in a new issue