Skip to content
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

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

Closed
wants to merge 1 commit into from

Conversation

Lung-Alexandra
Copy link
Contributor

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.

@nielsdos
Copy link
Member

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

@nielsdos
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 Lung-Alexandra changed the base branch from master to PHP-8.3 March 16, 2025 07:12
@TimWolla
Copy link
Member

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

@Lung-Alexandra
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

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

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 nielsdos closed this in 38e553e Mar 16, 2025
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
Projects
None yet
4 participants