xref: /PHP-8.2/ext/mysqli/tests/bug36420.phpt (revision b5a14e6c)
1--TEST--
2Bug #36420 (segfault when access result->num_rows after calling result->close())
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11
12require_once("connect.inc");
13$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
14
15$result = $mysqli->query('select 1');
16
17$result->close();
18try {
19    $result->num_rows;
20} catch (Error $exception) {
21    echo $exception->getMessage() . "\n";
22}
23
24$mysqli->close();
25try {
26    $result->num_rows;
27} catch (Error $exception) {
28    echo $exception->getMessage() . "\n";
29}
30
31echo "Done\n";
32?>
33--EXPECT--
34mysqli_result object is already closed
35mysqli_result object is already closed
36Done
37