Skip to content

Fix: reuse parsed performance JSON on error - #1154

Open
mattmundell wants to merge 2 commits into
mainfrom
fix/11-openvasd-openvasd-c-1314-parser-cjson-parse-resp-body-overwrites-the-parser-al
Open

mattmundell wants to merge 2 commits into
mainfrom
fix/11-openvasd-openvasd-c-1314-parser-cjson-parse-resp-body-overwrites-the-parser-al

Conversation

@mattmundell

Copy link
Copy Markdown
Contributor

What

Drop the second cJSON_Parse (resp->body) on the non-200 path of
openvasd_parsed_performance, reusing the parse taken before the status check
for the error item.

Why

openvasd_parsed_performance parsed the response body before the status check
and parsed it again on the non-200 path, overwriting the first cJSON tree and
leaking it and its children on every error response.

Testing

Before the change, openvasd_parsed_performance_error_response_frees_parser
(openvasd-test) leaked 160 bytes in 4 allocations from
openvasd_parsed_performance (openvasd/openvasd.c:195), a direct 64-byte cJSON
tree plus its indirect children. After the change the same case passes with no
ASan or LeakSanitizer report.

The error path parsed the response body again, leaking the first cJSON tree.
@mattmundell
mattmundell requested review from a team as code owners October 22, 2026 10:56
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA cecc874.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@greenbonebot
greenbonebot enabled auto-merge (rebase) October 22, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant