Fixed bug #68937 (Segfault in curl_multi_exec)

This commit is contained in:
Xinchen Hui 2015-01-30 13:12:58 +08:00
parent 56ab00b0fe
commit 73288bbea4
2 changed files with 38 additions and 2 deletions

View file

@ -1486,8 +1486,12 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_RES(&argv[1], t->res);
Z_ADDREF(argv[1]);
if (t->res) {
ZVAL_RES(&argv[1], t->res);
Z_ADDREF(argv[1]);
} else {
ZVAL_NULL(&argv[1]);
}
ZVAL_LONG(&argv[2], (int)size * nmemb);
fci.size = sizeof(fci);

View file

@ -0,0 +1,32 @@
--TEST--
Bug # #68937 (Segfault in curl_multi_exec)
--SKIPIF--
<?php
if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
include 'skipif.inc';
?>
--FILE--
<?php
$ch = curl_init('http://www.google.com/');
curl_setopt_array($ch, array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_INFILESIZE => 1,
CURLOPT_HTTPHEADER => array(
'Content-Length: 1',
),
CURLOPT_READFUNCTION => 'curl_read'
));
function curl_read($ch, $fp, $len) {
var_dump($fp);
exit;
}
curl_exec($ch);
curl_close($ch);
?>
--EXPECTF--
NULL