[php-src] PR #18082: Fix memory leaks in fuzzer modules detected by cppchecker #18081
| From: | Lung-Alexandra | Date: | Sat, 15 Mar 2025 22:12:47 +0000 |
| Subject: | [php-src] PR #18082: Fix memory leaks in fuzzer modules detected by cppchecker #18081 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31095@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18082
Author: Lung-Alexandra
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.