Never crash: PDF close-path operators and CFF outlines without a current point
The s, b and b* operators closed the path even when there was no current point, which kurbo asserts against (a panic in debug builds; found by fuzzing). Close only when a subpath is open. CFF charstrings that draw before their first rmoveto now start the subpath at the current point, as Type 1 charstrings already did. Denies the panic lints in the crate (it had no panic sites). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10644a83aa
commit
8e4e29844e
@@ -646,12 +646,21 @@ impl T2<'_> {
|
||||
self.path.move_to((self.x, self.y));
|
||||
self.open = true;
|
||||
}
|
||||
/// A segment before the first moveto starts at the current point.
|
||||
fn ensure_open(&mut self) {
|
||||
if !self.open {
|
||||
self.path.move_to((self.x, self.y));
|
||||
self.open = true;
|
||||
}
|
||||
}
|
||||
fn line_to(&mut self, dx: f64, dy: f64) {
|
||||
self.ensure_open();
|
||||
self.x += dx;
|
||||
self.y += dy;
|
||||
self.path.line_to((self.x, self.y));
|
||||
}
|
||||
fn curve(&mut self, d: [f64; 6]) {
|
||||
self.ensure_open();
|
||||
let (x1, y1) = (self.x + d[0], self.y + d[1]);
|
||||
let (x2, y2) = (x1 + d[2], y1 + d[3]);
|
||||
self.x = x2 + d[4];
|
||||
|
||||
Reference in New Issue
Block a user