Skip to content

fuzz_ppd: Fix memory leaks on early return paths - #59

Open
princemittalr wants to merge 1 commit into
OpenPrinting:mainfrom
princemittalr:fix/fuzz-ppd-memory-leaks
Open

fuzz_ppd: Fix memory leaks on early return paths#59
princemittalr wants to merge 1 commit into
OpenPrinting:mainfrom
princemittalr:fix/fuzz-ppd-memory-leaks

Conversation

@princemittalr

Copy link
Copy Markdown

Fixes #7

All strdup'd variables (ppdsize, legacy, pwg, ppdmedia, marked_option,
options_str) and dynamically allocated cups_options/cups_values arrays
were not freed when execution terminated early via return 1.

Refactored fuzz_ppd() to:

  • Initialize all pointers to NULL at declaration
  • Replace all early return 1 with goto cleanup
  • Add a single cleanup block at the bottom that safely frees all
    allocations regardless of which exit path was taken

This ensures OSS-Fuzz can focus on real bugs rather than false
positives from harness memory leaks.

All strdup'd variables (ppdsize, legacy, pwg, ppdmedia,
marked_option, options_str) and dynamically allocated
cups_options/cups_values arrays were not freed when
execution terminated early via return 1.

Refactored fuzz_ppd() to initialize all pointers to NULL
at declaration and use goto cleanup pattern so all
allocations are freed on every exit path.

Fixes: OpenPrinting#7
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.

Memory leak in cups fuzz_ppd harness

1 participant