xref: /PHP-8.4/ext/sqlite3/tests/bug53463.phpt (revision 7f2f0c00)
1--TEST--
2Bug #53463 (sqlite3 columnName() segfaults on bad column_number)
3--EXTENSIONS--
4sqlite3
5--FILE--
6<?php
7
8$db = new SQLite3(':memory:');
9
10$db->exec('CREATE TABLE test (whatever INTEGER)');
11$db->exec('INSERT INTO test (whatever) VALUES (1)');
12
13$result = $db->query('SELECT * FROM test');
14while ($row = $result->fetchArray(SQLITE3_NUM)) {
15    var_dump($result->columnName(0));  // string(8) "whatever"
16
17    // Seems returning false will be most appropriate.
18    var_dump($result->columnName(3));  // Segmentation fault
19}
20
21$result->finalize();
22$db->close();
23
24echo "Done\n";
25
26?>
27--EXPECT--
28string(8) "whatever"
29bool(false)
30Done
31