Skip to content

Commit

Permalink
Fix memory realted to #64726
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Apr 27, 2013
1 parent bf5506f commit c7b8368
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ext/mysqli/tests/bug64726.phpt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions ext/mysqlnd/mysqlnd_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c7b8368

Please sign in to comment.