xref: /PHP-8.1/ext/sqlite3/tests/bug69972.phpt (revision 7f2f0c00)
1--TEST--
2Bug #69972 (Use-after-free vulnerability in sqlite3SafetyCheckSickOrOk())
3--EXTENSIONS--
4sqlite3
5--FILE--
6<?php
7$db = new SQLite3(':memory:');
8echo "SELECTING from invalid table\n";
9$result = $db->query("SELECT * FROM non_existent_table");
10echo "Closing database\n";
11var_dump($db->close());
12echo "Done\n";
13
14// Trigger the use-after-free
15echo "Error Code: " . $db->lastErrorCode() . "\n";
16echo "Error Msg: " . $db->lastErrorMsg() . "\n";
17?>
18--EXPECTF--
19SELECTING from invalid table
20
21Warning: SQLite3::query(): Unable to prepare statement: 1, no such table: non_existent_table in %sbug69972.php on line %d
22Closing database
23bool(true)
24Done
25Error Code: 0
26Error Msg:
27