Skip to content

Commit 5fdfab7

Browse files
committed
Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes while curl_multi_exec)
1 parent 8442a1c commit 5fdfab7

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2016, PHP 5.6.19
44

5+
- CURL:
6+
. Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes
7+
while curl_multi_exec). (Laruence)
8+
59
- Date:
610
. Fixed bug #68078 (Datetime comparisons ignore microseconds). (Willem-Jan
711
Zijderveld)

ext/curl/interface.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,12 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC)
25432543
return 1;
25442544
}
25452545
}
2546-
zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
2546+
2547+
if (Z_REFCOUNT_P(ch->clone) <= 1) {
2548+
zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
2549+
} else {
2550+
zend_hash_next_index_insert(ch->to_free->slist, &slist, sizeof(struct curl_slist *), NULL);
2551+
}
25472552

25482553
error = curl_easy_setopt(ch->cp, option, slist);
25492554

ext/curl/tests/bug71523.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes while curl_multi_exec)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("curl")) {
6+
exit("skip curl extension not loaded");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$base = curl_init('http://www.google.com/');
13+
curl_setopt($base, CURLOPT_RETURNTRANSFER, true);
14+
$mh = curl_multi_init();
15+
16+
for ($i = 0; $i < 2; ++$i) {
17+
$ch = curl_copy_handle($base);
18+
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Foo: Bar']);
19+
curl_multi_add_handle($mh, $ch);
20+
}
21+
22+
do {
23+
curl_multi_exec($mh, $active);
24+
} while ($active);
25+
?>
26+
okey
27+
--EXPECTF--
28+
okey

0 commit comments

Comments
 (0)