1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix memory leaks in pdo_sqlite callback registration

* We need to clean the trampoline if the construction check fails
* Checking for an exception and then returning causes a leak on
  `collation`. Returning early is pointless anyway.

Closes GH-17904.
This commit is contained in:
Niels Dossche
2025-02-23 15:06:07 +01:00
parent 76035090b6
commit 635fe263ac
2 changed files with 8 additions and 7 deletions

1
NEWS
View File

@@ -60,6 +60,7 @@ PHP NEWS
. Fixed GH-17837 ()::getColumnMeta() on unexecuted statement segfaults).
(cmb)
. Fix cycle leak in sqlite3 setAuthorizer(). (nielsdos)
. Fix memory leaks in pdo_sqlite callback registration. (nielsdos)
- Phar:
. Fixed bug GH-17808: PharFileInfo refcount bug. (nielsdos)

View File

@@ -513,7 +513,7 @@ void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_END_EX(goto error;);
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
PDO_CONSTRUCT_CHECK_WITH_CLEANUP(error);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -571,7 +571,7 @@ void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_END_EX(goto error;);
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
PDO_CONSTRUCT_CHECK_WITH_CLEANUP(error);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -643,7 +643,7 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
ZEND_PARSE_PARAMETERS_END();
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
PDO_CONSTRUCT_CHECK_WITH_CLEANUP(cleanup_fcc);
H = (pdo_sqlite_db_handle *)dbh->driver_data;
@@ -663,12 +663,12 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
zend_release_fcall_info_cache(&fcc);
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
efree(collation);
RETURN_FALSE;
cleanup_fcc:
zend_release_fcall_info_cache(&fcc);
RETURN_THROWS();
}
/* {{{ bool SQLite::sqliteCreateCollation(string name, callable callback)