Skip to content

Commit b612559

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79199: curl_copy_handle() memory leak
2 parents 208e348 + ddc3f3d commit b612559

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

ext/curl/interface.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,8 +2150,6 @@ PHP_FUNCTION(curl_copy_handle)
21502150
}
21512151
#endif
21522152

2153-
Z_ADDREF_P(zid);
2154-
21552153
ZVAL_RES(return_value, zend_register_resource(dupch, le_curl));
21562154
dupch->res = Z_RES_P(return_value);
21572155
}

ext/curl/tests/bug79199.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #79199 (curl_copy_handle() memory leak)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('curl')) die('skip curl extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$mem_old = 0;
10+
for($i = 0; $i < 50; ++$i) {
11+
$c1 = curl_init();
12+
$c2 = curl_copy_handle($c1);
13+
curl_close($c2);
14+
curl_close($c1);
15+
$mem_new = memory_get_usage();
16+
if ($mem_new <= $mem_old) {
17+
break;
18+
}
19+
$mem_old = $mem_new;
20+
}
21+
echo $i < 50 ? "okay" : "leak", PHP_EOL;
22+
?>
23+
--EXPECT--
24+
okay

0 commit comments

Comments
 (0)