Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix memory leaks in fuzzer modules detected by cppchecker #18081 #18082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Lung-Alexandra wants to merge 1 commit into php:PHP-8.3 from Lung-Alexandra:fix/memory-leak

Conversation

Copy link
Contributor

@Lung-Alexandra Lung-Alexandra commented Mar 15, 2025

This PR fixes #18081.

This pull request addresses several memory leak issues detected by cppchecker in the following files:

  • fuzzer-json.c (line 39):
    Added a free(data) call to release the allocated memory before returning.

  • fuzzer-mbregex.c (line 39):
    Implemented a similar fix by freeing the allocated memory for data when fuzzer_request_startup() fails.

  • fuzzer-unserialize.c (line 38):
    Now frees orig_data before returning when an error is detected.

  • fuzzer-unserializehash.c (line 43):
    Modified the error path to call free(orig_data) if fuzzer_request_startup() fails.

These changes ensure that memory allocated is properly released if fuzzer_request_startup() fails, preventing memory leaks.

Copy link
Member

This affects lower branches too, please target the lowest supported bugfix branch, i.e. PHP-8.3.

Lung-Alexandra reacted with thumbs up emoji

Copy link
Member

It's probably also better to just move the allocation under the request initialization, then you don't even need the call to free.

Lung-Alexandra reacted with thumbs up emoji

Copy link
Member

This needs to be properly rebased when changing the target branch.

Copy link
Contributor Author

@TimWolla squashed and rebased over PHP-8.3

Copy link
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs vs spaces mixed up in all files

nielsdos reacted with thumbs up emoji
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix indentation to use tabs

Lung-Alexandra reacted with thumbs up emoji
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

nielsdos added a commit that referenced this pull request Mar 16, 2025
* PHP-8.3:
 Fix GH-18082: Memory leaks in fuzzer SAPI error paths
nielsdos added a commit that referenced this pull request Mar 16, 2025
* PHP-8.4:
 Fix GH-18082: Memory leaks in fuzzer SAPI error paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@nielsdos nielsdos nielsdos approved these changes

+1 more reviewer

@staabm staabm staabm left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Projects
None yet
Milestone
No milestone

AltStyle によって変換されたページ (->オリジナル) /