xref: /PHP-8.1/ext/sqlite3/tests/bug66550.phpt (revision 7f2f0c00)
1--TEST--
2Bug #66550 (SQLite prepared statement use-after-free)
3--EXTENSIONS--
4sqlite3
5--FILE--
6<?php
7
8$db = new SQLite3(':memory:');
9
10$db->exec('CREATE TABLE foo (id INTEGER, bar STRING)');
11
12$stmt = $db->prepare('SELECT bar FROM foo WHERE id=:id');
13// Close the database connection and free the internal sqlite3_stmt object
14$db->close();
15// Access the sqlite3_stmt object via the php_sqlite3_stmt container
16try {
17    $stmt->reset();
18} catch (\Error $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21?>
22--EXPECT--
23The SQLite3 object has not been correctly initialised or is already closed
24