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

Fix memory leak on error return of collation callback in pdo_sqlite

We should destroy it when it's not IS_LONG, not when it's IS_LONG.

Closes GH-18332.
This commit is contained in:
Niels Dossche
2025-04-16 00:23:48 +02:00
parent bfa2cfc9ed
commit ce7304f909
2 changed files with 4 additions and 1 deletions

3
NEWS
View File

@@ -45,6 +45,9 @@ PHP NEWS
. Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted"
with setAttribute() (SakiTakamachi).
- PDO Sqlite:
. Fix memory leak on error return of collation callback. (nielsdos)
- SPL:
. Fixed bug GH-18322 (SplObjectStorage debug handler mismanages memory).
(nielsdos)

View File

@@ -352,6 +352,7 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v
zend_type_error("%s(): Return value of the callback must be of type int, %s returned",
ZSTR_VAL(func_name), zend_zval_value_name(&retval));
zend_string_release(func_name);
zval_ptr_dtor(&retval);
return FAILURE;
}
if (Z_LVAL(retval) > 0) {
@@ -359,7 +360,6 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v
} else if (Z_LVAL(retval) < 0) {
ret = -1;
}
zval_ptr_dtor(&retval);
}
zval_ptr_dtor(&zargs[0]);