Skip to content

Commit f9226f9

Browse files
committed
Fix bug #73949 leak in mysqli_fetch_object
1 parent fb8486f commit f9226f9

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ PHP NEWS
2323
. Fixed bug #73933 (error/segfault with ldap_mod_replace and opcache).
2424
(Laruence)
2525

26+
- MySQLi:
27+
. Fixed bug #73949 (leak in mysqli_fetch_object). (krakjoe)
28+
2629
- Mysqlnd:
2730
. Fixed bug #69899 (segfault on close() after free_result() with mysqlnd).
2831
(Richard Fussenegger)

ext/mysqli/mysqli.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,9 +1324,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
13241324
} else {
13251325
zval_ptr_dtor(&retval);
13261326
}
1327-
if (fci.params) {
1328-
efree(fci.params);
1329-
}
1327+
zend_fcall_info_args_clear(&fci, 1);
13301328
} else if (ctor_params) {
13311329
zend_throw_exception_ex(zend_ce_exception, 0, "Class %s does not have a constructor hence you cannot use ctor_params", ZSTR_VAL(ce->name));
13321330
}

ext/mysqli/tests/bug73949.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #73949 (leak in mysqli_fetch_object)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifemb.inc');
7+
require_once('skipifconnectfailure.inc');
8+
?>
9+
--FILE--
10+
<?php
11+
require_once("connect.inc");
12+
13+
class cc{
14+
function __construct($c=null){
15+
}
16+
};
17+
$i=mysqli_connect('p:'.$host, $user, $passwd, $db);
18+
$res=mysqli_query($i, "SHOW STATUS LIKE 'Connections'");
19+
$t=array(new stdClass);
20+
while($db= mysqli_fetch_object($res,'cc',$t)){}
21+
print "done!";
22+
?>
23+
--EXPECTF--
24+
done!

0 commit comments

Comments
 (0)