xref: /php-src/ext/mysqli/tests/bug33491.phpt (revision a21edc52)
1--TEST--
2Bug #33491 (extended mysqli class crashes when result is not object)
3--INI--
4error_reporting=1
5--EXTENSIONS--
6mysqli
7--SKIPIF--
8<?php
9require_once 'skipifconnectfailure.inc';
10?>
11--FILE--
12<?php
13
14class DB extends mysqli
15{
16  public function query_single($query) {
17    $result = parent::query($query);
18    $result->fetch_row(); // <- Here be crash
19  }
20}
21
22require_once 'connect.inc';
23
24// Segfault when using the DB class which extends mysqli
25$DB = new DB($host, $user, $passwd, $db, $port, $socket);
26$DB->query_single('SELECT DATE()');
27
28?>
29--EXPECTF--
30Fatal error: Uncaught Error: Call to a member function fetch_row() on false in %sbug33491.php:%d
31Stack trace:
32#0 %s(%d): DB->query_single('SELECT DATE()')
33#1 {main}
34  thrown in %sbug33491.php on line %d
35