Harden against badly-compressed data

This commit is contained in:
John Whitington 2024-12-18 19:29:18 +00:00
parent f28e87cbac
commit c6a0c057b8

View File

@ -25,7 +25,7 @@ let recompress_stream pdf = function
| Some (Pdf.Array []
| Pdf.Array (Pdf.Name ("/ASCIIHexDecode" | "/ASCII85Decode" | "/LZWDecode" | "/RunLengthDecode")::_)
)), _ ->
Pdfcodec.decode_pdfstream_until_unknown pdf stream;
begin try Pdfcodec.decode_pdfstream_until_unknown pdf stream with _ -> Pdfe.log "Warning: Skipping re-encoding of a stream\n" end;
Pdfcodec.encode_pdfstream ~only_if_smaller:true pdf Pdfcodec.Flate stream
| _ -> ()
end