Skip to content

Commit 4306416

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-13998: Manage refcount of agg_context->val correctly (#14004)
2 parents 4393198 + 2a1aa8c commit 4306416

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ PHP NEWS
4444

4545
- PDO SQLite:
4646
. Fix GH-13984 (Buffer size is now checked before memcmp). (Saki Takamachi)
47+
. Fix GH-13998 (Manage refcount of agg_context->val correctly).
48+
(Saki Takamachi)
4749

4850
- Phar:
4951
. Fixed bug GH-13836 (Renaming a file in a Phar to an already existing

ext/pdo_sqlite/sqlite_driver.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb,
428428
* the context */
429429
if (agg_context) {
430430
if (Z_ISUNDEF(retval)) {
431-
zval_ptr_dtor(&agg_context->val);
432431
return FAILURE;
433432
}
434433
zval_ptr_dtor(Z_REFVAL(agg_context->val));

ext/pdo_sqlite/tests/gh13998.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Fix GH-13998: Manage refcount of agg_context->val correctly
3+
--EXTENSIONS--
4+
pdo_sqlite
5+
--FILE--
6+
<?php
7+
$step = function () {
8+
throw new Exception();
9+
};
10+
$finalize = function () {
11+
};
12+
13+
$db = new PDO('sqlite::memory:');
14+
$db->query('CREATE TABLE test (a int, b int)');
15+
$stmt = $db->query('INSERT INTO test VALUES (1, 1), (2, 2), (3, 3)');
16+
$db->sqliteCreateAggregate('S', $step, $finalize, 1);
17+
18+
try {
19+
$db->query('SELECT S(a) FROM test');
20+
} catch (Exception $e) {
21+
echo 'done!';
22+
}
23+
?>
24+
--EXPECT--
25+
done!

0 commit comments

Comments
 (0)