Skip to content

Mysqli mem fixes#21930

Open
devnexen wants to merge 2 commits intophp:PHP-8.4from
devnexen:mysqli_mem_fixes
Open

Mysqli mem fixes#21930
devnexen wants to merge 2 commits intophp:PHP-8.4from
devnexen:mysqli_mem_fixes

Conversation

@devnexen
Copy link
Copy Markdown
Member

@devnexen devnexen commented May 2, 2026

No description provided.

devnexen added 2 commits May 2, 2026 05:27
… errors.

When MYSQLI_REPORT_INDEX is enabled, mysqli_execute_query() duplicates
the query string into stmt->query. The two input_params validation
error branches freed the MY_STMT wrapper directly without releasing
stmt->query, leaking the duplicated string per failing call.
@devnexen devnexen marked this pull request as ready for review May 2, 2026 05:20
@kamil-tekiela
Copy link
Copy Markdown
Member

This was copied from mysqli_prepare. Doesn't it leak memory too?

@devnexen
Copy link
Copy Markdown
Member Author

devnexen commented May 2, 2026

Checked it, I think prepare is actually fine. The estrdup there is guarded by stmt->stmt being non-NULL, and the efree(stmt) early-return only runs when stmt->stmt is
NULL, so they can't both happen. stmt->query stays NULL on the failure path.

The reason execute_query leaks is the order, the estrdup runs before the input_params checks, and those checks bail with efree(stmt) without touching the dup. Same
snippet, different surrounding flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants