xref: /PHP-8.0/ext/sqlite3/tests/bug53463.phpt (revision d679f022)
1--TEST--
2Bug #53463 (sqlite3 columnName() segfaults on bad column_number)
3--SKIPIF--
4<?php require_once(__DIR__ . '/skipif.inc'); ?>
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