From c6a0c057b817af00ca5bb6bf0a1b5b2c53e06a96 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 18 Dec 2024 19:29:18 +0000 Subject: [PATCH] Harden against badly-compressed data --- cpdfsqueeze.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpdfsqueeze.ml b/cpdfsqueeze.ml index 810b74a..a0d072a 100644 --- a/cpdfsqueeze.ml +++ b/cpdfsqueeze.ml @@ -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