pdftoraster: extract copy_image_rows() helper and add an ASan regression test - #206
Merged
tillkamppeter merged 1 commit intoAug 9, 2026
Merged
Conversation
rkt0209
force-pushed
the
test-pdftoraster-real-fn
branch
from
August 9, 2026 11:31
782c261 to
186ea1e
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.
Follow-up to the review on #204: the standalone
test-pdftoraster-copy-height.cre-implemented the copy loop, so it would pass even if the realwrite_page_image()regressed. This makes the test drive the real library code.Refactor (no behaviour change): the copy loop in
write_page_image()is extracted into astatic void copy_image_rows(...)thatwrite_page_image()now calls. The loop body is unchanged (existing filter tests still pass).Test:
test-pdftoraster-copy-height.c#includes the in-treecupsfilters/pdftoraster.cto reach the static helper and its types, then callscopy_image_rows()under AddressSanitizer with acolordatabuffer sized to exactlycopy_heightrows whilecupsHeightis one row taller — the "rendered image shorter than page" case where the off-by-one lived. The buggyh <= copy_heightreads one row past the buffer and ASan aborts; the fixedh < copy_heightstays in bounds. Deterministic, no pdftoppm needed.The
.shwrapper builds it under ASan and skips (Automake exit 77) when ASan is unavailable; the.cis listed inEXTRA_DISTso it ships inmake dist.Verified: fixed code PASS, buggy code FAIL (ASan heap-buffer-overflow in
copy_image_rows), across system-2x / source-2.5.x / source-3.x.