Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix GH-13998: Manage refcount of agg_context->val correctly (#14004)
This commit is contained in:
Saki Takamachi 2024-04-20 22:34:31 +09:00
commit 43064160c4
No known key found for this signature in database
GPG Key ID: E4A36F6D37931A8B
3 changed files with 27 additions and 1 deletions

2
NEWS
View File

@ -44,6 +44,8 @@ PHP NEWS
- PDO SQLite:
. Fix GH-13984 (Buffer size is now checked before memcmp). (Saki Takamachi)
. Fix GH-13998 (Manage refcount of agg_context->val correctly).
(Saki Takamachi)
- Phar:
. Fixed bug GH-13836 (Renaming a file in a Phar to an already existing

View File

@ -428,7 +428,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));

View File

@ -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!