Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion ext/pdo_sqlite/sqlite_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb,
* the context */
if (agg_context) {
if (Z_ISUNDEF(retval)) {
zval_ptr_dtor(&agg_context->val);
return FAILURE;
}
zval_ptr_dtor(Z_REFVAL(agg_context->val));
Expand Down
25 changes: 25 additions & 0 deletions ext/pdo_sqlite/tests/gh13998.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Fix GH-13998: Manage refcount of agg_context->val correctly
--EXTENSIONS--
pdo_sqlite
--FILE--
<?php
$step = function () {
throw new Exception();
};
$finalize = function () {
};

$db = new PDO('sqlite::memory:');
$db->query('CREATE TABLE test (a int, b int)');
$stmt = $db->query('INSERT INTO test VALUES (1, 1), (2, 2), (3, 3)');
$db->sqliteCreateAggregate('S', $step, $finalize, 1);

try {
$db->query('SELECT S(a) FROM test');
} catch (Exception $e) {
echo 'done!';
}
?>
--EXPECT--
done!