LibPDF: Clear arguments of unknown operators

This is a follow-up to #26905: If an unknown operator had arguments,
we used to not clear them, causing the next known operator to
receive them.

To test, call an unknown operator with a non-number arg,
followed by `re`.
This commit is contained in:
Nico Weber committed 2026-07-29 20:47:02 -04:00
1 parent d8c9bc03bb
commit 3ef7fb18dc
2 files changed
+6 -2

No files matched your search

+5 -2
View File
@@ -14,11 +14,14 @@ endobj
endobj
4 0 obj
<</Length 5>>
<</Length 52>>
stream
q
QQ
() anotherunknownopwithanarg
0 0 100 100 re f
endstream
endobj
@@ -33,5 +36,5 @@ xref
trailer
<</Size 5/Root 1 0 R>>
startxref
248
296
%%EOF
+1
View File
@@ -602,6 +602,7 @@ PDFErrorOr<Vector<Operator>> Parser::parse_operators()
// but we ignore them everywhere. All other engines seem to do that too, so some files depend on it.
// (Usually accidentally, e.g. containing "QQ" instead of "Q Q" or similar.)
dbgln("ignoring unknown operator \"{}\"", operator_string);
operator_args.clear();
continue;
}
auto operator_type = maybe_operator_type.release_value();