Skip to content

Commit 3d9a0a0

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17837: ::getColumnMeta() on unexecuted statement segfaults
2 parents da38477 + 4a514f6 commit 3d9a0a0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/pdo_sqlite/sqlite_statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret
305305
const char *str;
306306
zval flags;
307307

308-
if (!S->stmt) {
308+
if (!S->stmt || !stmt->executed) {
309309
return FAILURE;
310310
}
311311
if(colno >= sqlite3_column_count(S->stmt)) {

ext/pdo_sqlite/tests/gh17837.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-17837 (::getColumnMeta() on unexecuted statement segfaults)
3+
--EXTENSIONS--
4+
pdo_sqlite
5+
--CREDITS--
6+
YuanchengJiang
7+
--FILE--
8+
<?php
9+
$db = new PDO('sqlite::memory:');
10+
$stmt = $db->prepare('select :a, :b, ?');
11+
var_dump($stmt->getColumnMeta(0));
12+
?>
13+
--EXPECT--
14+
bool(false)

0 commit comments

Comments
 (0)