Skip to content

Commit ce7304f

Browse files
committed
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.
1 parent bfa2cfc commit ce7304f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ PHP NEWS
4545
. Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted"
4646
with setAttribute() (SakiTakamachi).
4747

48+
- PDO Sqlite:
49+
. Fix memory leak on error return of collation callback. (nielsdos)
50+
4851
- SPL:
4952
. Fixed bug GH-18322 (SplObjectStorage debug handler mismanages memory).
5053
(nielsdos)

Diff for: ext/pdo_sqlite/pdo_sqlite.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,14 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v
352352
zend_type_error("%s(): Return value of the callback must be of type int, %s returned",
353353
ZSTR_VAL(func_name), zend_zval_value_name(&retval));
354354
zend_string_release(func_name);
355+
zval_ptr_dtor(&retval);
355356
return FAILURE;
356357
}
357358
if (Z_LVAL(retval) > 0) {
358359
ret = 1;
359360
} else if (Z_LVAL(retval) < 0) {
360361
ret = -1;
361362
}
362-
zval_ptr_dtor(&retval);
363363
}
364364

365365
zval_ptr_dtor(&zargs[0]);

0 commit comments

Comments
 (0)