[php-src] master: Merge branch 'PHP-8.5'

From: Date: Mon, 03 Aug 2026 20:56:06 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140457@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-08-03T22:55:56+02:00 Commit: https://github.com/php/php-src/commit/430a21f40bfc520c752c3a1052a68d463a7177d5 Raw diff: https://github.com/php/php-src/commit/430a21f40bfc520c752c3a1052a68d463a7177d5.diff Merge branch 'PHP-8.5' * PHP-8.5: sqlite3: Fix leak when trying to close db if blob stream is still open Changed paths: A ext/sqlite3/tests/sqlite3_close_blob_stream.phpt M ext/sqlite3/sqlite3.c Diff: diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 57271a629423..45918923c1cb 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2314,7 +2314,9 @@ static void php_sqlite3_object_free_storage(zend_object *object) /* {{{ */ } if (intern->initialised && intern->db) { - sqlite3_close(intern->db); + /* Use sqlite3_close_v2() because the object may be destroyed while resources depending on the connection are still alive, + * e.g. a blob stream created by SQLite3::openBlob(). */ + sqlite3_close_v2(intern->db); intern->initialised = false; } diff --git a/ext/sqlite3/tests/sqlite3_close_blob_stream.phpt b/ext/sqlite3/tests/sqlite3_close_blob_stream.phpt new file mode 100644 index 000000000000..d2426445a7cd --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_close_blob_stream.phpt @@ -0,0 +1,22 @@ +--TEST-- +Destroying the SQLite3 object while a blob stream is still open must not leak the connection +--EXTENSIONS-- +sqlite3 +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +$db->exec('CREATE TABLE test (data BLOB)'); +$db->exec("INSERT INTO test (data) VALUES (x'34323432')"); + +$stream = $db->openBlob('test', 'data', 1); +var_dump($db->close()); +unset($db); +var_dump(fread($stream, 4)); +fclose($stream); + +?> +--EXPECTF-- +Warning: SQLite3::close(): Unable to close database: %s in %s on line %d +bool(false) +string(4) "4242"

« previous php.cvs (#140457) next »