dev/cppcheck: add minimal reproducer for memleakOnRealloc false positive#36
Draft
Copilot wants to merge 3 commits into
Draft
dev/cppcheck: add minimal reproducer for memleakOnRealloc false positive#36Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
fixes haproxy#2124 src/cpuset.c:21:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn] src/cpuset.c:36:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn] src/cpuset.c:100:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn] src/cpuset.c:124:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn] src/cpuset.c:152:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn] src/cpuset.c:163:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
Agent-Logs-Url: https://github.com/chipitsine/haproxy/sessions/22546775-a4d6-4dfa-a5dd-260b88401915 Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create minimal reproducer for cppcheck false positive
dev/cppcheck: add minimal reproducer for memleakOnRealloc false positive
May 3, 2026
a9066f4 to
c090e51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cppcheck incorrectly reports
[memleakOnRealloc]insrc/quic_rx.c:819(qc_try_store_new_token) because it doesn't track that a local copy of a struct-held pointer preserves the original allocation through the failure path.Changes
dev/cppcheck/cppcheck_test.c— self-contained C file (no haproxy headers) that reproduces the false positive with stripped-down types mirroring the original pattern:cppcheck sees
local_ptrnulled on realloc failure and assumes the original allocation is lost, not realisingb->ptrstill holds it and theelsebranch frees it. The file is ready to submit as a cppcheck upstream bug report.