summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2017-01-18 18:24:14 +0000
committerJoe Watkins <krakjoe@php.net>2017-01-18 18:24:49 +0000
commit5bc81620ef57cb7315f254531ccfaac9c523f97d (patch)
treeb2858d4f45617cebf1b5e288a73ffee7654eb206
parent409467dc2f7dcd9586dda4855c2f404ebdf1d5c9 (diff)
parent6d89640d55169e3c72208e7199767c45a6469577 (diff)
downloadphp-git-5bc81620ef57cb7315f254531ccfaac9c523f97d.tar.gz
Merge branch 'PHP-7.1'
* PHP-7.1: Fix bug #73949 leak in mysqli_fetch_object
-rw-r--r--NEWS3
-rw-r--r--ext/mysqli/mysqli.c4
-rw-r--r--ext/mysqli/tests/bug73949.phpt24
3 files changed, 28 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index f6375a7bb4..82b0bee72d 100644
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,9 @@ PHP NEWS
- Mcrypt:
. The deprecated mcrypt extension has been moved to PECL. (leigh)
+- MySQLi:
+ . Fixed bug #73949 (leak in mysqli_fetch_object). (krakjoe)
+
- mysqlnd:
. Fixed bug #73800 (sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE).
(vanviegen)
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 08fb82154b..00a9497fca 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -1318,9 +1318,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
} else {
zval_ptr_dtor(&retval);
}
- if (fci.params) {
- efree(fci.params);
- }
+ zend_fcall_info_args_clear(&fci, 1);
} else if (ctor_params) {
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));
}
diff --git a/ext/mysqli/tests/bug73949.phpt b/ext/mysqli/tests/bug73949.phpt
new file mode 100644
index 0000000000..7ce311eb77
--- /dev/null
+++ b/ext/mysqli/tests/bug73949.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #73949 (leak in mysqli_fetch_object)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+require_once("connect.inc");
+
+class cc{
+ function __construct($c=null){
+ }
+};
+$i=mysqli_connect('p:'.$host, $user, $passwd, $db);
+$res=mysqli_query($i, "SHOW STATUS LIKE 'Connections'");
+$t=array(new stdClass);
+while($db= mysqli_fetch_object($res,'cc',$t)){}
+print "done!";
+?>
+--EXPECTF--
+done!