Skip to content

Commit 938bbb8

Browse files
committed
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.
1 parent 2c911e4 commit 938bbb8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/pdo_sqlite/sqlite_driver.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
513513
ZEND_PARSE_PARAMETERS_END_EX(goto error;);
514514

515515
dbh = Z_PDO_DBH_P(ZEND_THIS);
516-
PDO_CONSTRUCT_CHECK;
516+
PDO_CONSTRUCT_CHECK_WITH_CLEANUP(error);
517517

518518
H = (pdo_sqlite_db_handle *)dbh->driver_data;
519519

@@ -643,7 +643,7 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
643643
ZEND_PARSE_PARAMETERS_END();
644644

645645
dbh = Z_PDO_DBH_P(ZEND_THIS);
646-
PDO_CONSTRUCT_CHECK;
646+
PDO_CONSTRUCT_CHECK_WITH_CLEANUP(cleanup_fcc);
647647

648648
H = (pdo_sqlite_db_handle *)dbh->driver_data;
649649

@@ -663,12 +663,12 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
663663

664664
zend_release_fcall_info_cache(&fcc);
665665

666-
if (UNEXPECTED(EG(exception))) {
667-
RETURN_THROWS();
668-
}
669-
670666
efree(collation);
671667
RETURN_FALSE;
668+
669+
cleanup_fcc:
670+
zend_release_fcall_info_cache(&fcc);
671+
RETURN_THROWS();
672672
}
673673

674674
/* {{{ bool SQLite::sqliteCreateCollation(string name, callable callback)

0 commit comments

Comments
 (0)