Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ static void pdo_get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */
pdo_row_t *row = zend_object_alloc(sizeof(pdo_row_t), pdo_row_ce);
row->stmt = stmt;
zend_object_std_init(&row->std, pdo_row_ce);
object_properties_init(&row->std, pdo_row_ce);
stmt->lazy_object_ref = &row->std;
GC_ADDREF(&stmt->std);
GC_DELREF(&row->std);
Expand Down Expand Up @@ -2405,6 +2406,7 @@ static zend_object *pdo_row_new(zend_class_entry *ce)
{
pdo_row_t *row = zend_object_alloc(sizeof(pdo_row_t), ce);
zend_object_std_init(&row->std, ce);
object_properties_init(&row->std, pdo_row_ce);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question ; would ce just work here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it would, in this case it's always the same. But it's cleaner to use ce. This is a copy-pasta leftover. Thanks for noticing


return &row->std;
}
Expand Down
17 changes: 17 additions & 0 deletions ext/pdo_sqlite/tests/gh18114.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
GH-18114 (pdo lazy object crash)
--EXTENSIONS--
pdo_sqlite
--XLEAK--
See https://github.com/php/php-src/issues/18114#issuecomment-2738069692, will be fixed in a later PR on lower branches
--FILE--
<?php
$db = new PDO('sqlite::memory:');
$x = $db->query('select 1 as queryString');
foreach ($x->fetch(PDO::FETCH_LAZY) as $entry) {
var_dump($entry);
}
echo "Done\n";
?>
--EXPECT--
Done
Loading