mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-02 06:28:49 -06:00
A content stream that uses l, c, v, y or h before any m or re has no subpath to extend. The edit-side image scan (crates/edit/src/images.rs) handed the operators straight to BezPath's line_to/curve_to/close_path, which panic on an empty path by contract, so object_list, page_images, image_hit and the Office export's image walk all crashed on such a page, while the renderer, text extraction, MuPDF and pdftotext skip the malformed segment and render the rest. The scan now skips the segment when the path has no elements, mirroring the v arm's existing guard and kurbo's own condition (debug_assert on !is_empty). A path started with m or re extends and closes exactly as before. A clip set by a stray segment (W n on an empty path) takes a zero bounding box, which kurbo defines as Rect::default, not a panic. Regression test: each of the five segment operators before any m, then a well-formed m l h and a re W n clip, all before an image Do - the image is still listed in every case. Verified against kurbo 0.13.1's source (line_to/curve_to/close_path debug_assert on empty; bounding_box unwrap_or_default) and the issue's repro; no Rust toolchain on this machine, so cargo test was not run here - saying so plainly for the reviewer. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>