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