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