diff options
-rw-r--r-- | ext/mysqli/mysqli.c | 2 | ||||
-rw-r--r-- | ext/mysqli/tests/bug64726.phpt | 23 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 1 |
3 files changed, 25 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 1731bb70f4..d14b616827 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1271,7 +1271,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags php_mysqli_fetch_into_hash_aux(return_value, result, fetchtype TSRMLS_CC); - if (into_object && Z_TYPE_P(return_value) != IS_NULL) { + if (into_object && Z_TYPE_P(return_value) == IS_ARRAY) { zval dataset = *return_value; zend_fcall_info fci; zend_fcall_info_cache fcc; diff --git a/ext/mysqli/tests/bug64726.phpt b/ext/mysqli/tests/bug64726.phpt new file mode 100644 index 0000000000..1f9bbaa93e --- /dev/null +++ b/ext/mysqli/tests/bug64726.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #63398 (Segfault 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 7ab7d00161..b4725feb2b 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -1479,6 +1479,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); |