com php-src: Fix memory realted to #64726: ext/mysqli/tests/bug64726.phpt ext/mysqlnd/mysqlnd_result.c
| From: | Xinchen Hui | Date: | Sat, 27 Apr 2013 15:38:00 +0000 |
| Subject: | com php-src: Fix memory realted to #64726: ext/mysqli/tests/bug64726.phpt ext/mysqlnd/mysqlnd_result.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72049@lists.php.net to get a copy of this message | ||
Commit: c7b8368ed579ddd539af95427902215f0530b4ea
Author: Xinchen Hui <laruence@php.net> Sat, 27 Apr 2013 23:36:56 +0800
Parents: bf5506f511e66a2b827988d611ccda4d75abc44e
Branches: PHP-5.3 PHP-5.4 PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c7b8368ed579ddd539af95427902215f0530b4ea
Log:
Fix memory realted to #64726
Bugs:
https://bugs.php.net/64726
Changed paths:
A ext/mysqli/tests/bug64726.phpt
M ext/mysqlnd/mysqlnd_result.c
Diff:
diff --git a/ext/mysqli/tests/bug64726.phpt b/ext/mysqli/tests/bug64726.phpt
new file mode 100644
index 0000000..3e43916
--- /dev/null
+++ b/ext/mysqli/tests/bug64726.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #63398 (Memleak when calling fetch_object on a use_result and DB pointer has closed)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once("connect.inc");
+if (!$IS_MYSQLND) {
+ die("skip mysqlnd only test");
+}
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+require 'connect.inc';
+$db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
+
+$result = $db->query('SELECT 1', MYSQLI_USE_RESULT);
+$db->close();
+var_dump($result->fetch_array());
+?>
+--EXPECTF--
+Warning: mysqli_result::fetch_array(): Error while reading a row in %sbug64726.php on line %d
+bool(false)
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 884de8b..a5ea3c4 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1547,6 +1547,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, unsigned int
flags
mysqlnd_array_init(return_value, mysqlnd_num_fields(result) * 2);
if (FAIL == result->m.fetch_row(result, (void *)return_value, flags, &fetched_anything
TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while reading a row");
+ zval_dtor(return_value);
RETVAL_FALSE;
} else if (fetched_anything == FALSE) {
zval_dtor(return_value);