Skip to content

Commit 088776e

Browse files
committed
mysqli: Fix memory leak in mysqli_execute_query()
The argument-validation error paths free stmt directly, leaking the estrdup'd stmt->query copy made under MYSQLI_REPORT_INDEX.
1 parent 17f6752 commit 088776e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ext/mysqli/mysqli_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,9 @@ PHP_FUNCTION(mysqli_execute_query)
534534
if (!zend_array_is_list(input_params)) {
535535
mysqli_stmt_close(stmt->stmt, false);
536536
stmt->stmt = NULL;
537+
if (stmt->query) {
538+
efree(stmt->query);
539+
}
537540
efree(stmt);
538541
zend_argument_value_error(ERROR_ARG_POS(3), "must be a list array");
539542
RETURN_THROWS();
@@ -544,6 +547,9 @@ PHP_FUNCTION(mysqli_execute_query)
544547
if (hash_num_elements != param_count) {
545548
mysqli_stmt_close(stmt->stmt, false);
546549
stmt->stmt = NULL;
550+
if (stmt->query) {
551+
efree(stmt->query);
552+
}
547553
efree(stmt);
548554
zend_argument_value_error(ERROR_ARG_POS(3), "must consist of exactly %d elements, %d present", param_count, hash_num_elements);
549555
RETURN_THROWS();

0 commit comments

Comments
 (0)