Skip to content

fix double free of ppdsizename in generate_cluster_conflicts - #89

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-cluster-conflicts-double-free
Nov 24, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-cluster-conflicts-double-free

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

Summary

ppdsizename is a single 128-byte scratch buffer allocated once and reused for every page size while building the cluster's PageSize option array.

The bug

Each loop iteration added that same pointer to pagesizes with no de-dup check at all, so a printer supporting N standard sizes (any real printer supports several) left N copies of the identical pointer in the array. cupsArrayDelete() calls free() on every element it still holds, so it frees that one pointer N times once the cluster's conflict table is torn down.

Fix

Add a strdup() of the buffer's current contents instead of the raw scratch pointer, so each entry is independently owned and freed exactly once.

Test plan

  • Code-traced against current upstream/master: the buggy line (cupsArrayAdd(pagesizes, ppdsizename)) and the surrounding allocation/array-destructor setup are unchanged, so the bug is still present and reachable exactly as described.

…licts

ppdsizename is a single 128-byte scratch buffer allocated once and
reused for every page size while building the cluster's PageSize
option array. Each loop iteration added that same pointer to
"pagesizes" with no de-dup check at all, so a printer supporting N
standard sizes (any real printer supports several) left N copies of
the identical pointer in the array. cupsArrayDelete() calls free() on
every element it still holds, so it frees that one pointer N times
once the cluster's conflict table is torn down. Add a strdup() of the
buffer's current contents instead of the raw scratch pointer, so each
entry is independently owned and freed exactly once.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@tillkamppeter
tillkamppeter merged commit 753fb42 into OpenPrinting:master Nov 24, 2026
11 checks passed
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.

3 participants