From e098977f0ade8338dcb4504ea105c1e28cf62fcc Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Tue, 15 Jun 2021 11:57:41 +0200 Subject: [PATCH] Fix a pattern-match failure when decoder is closed and we don't have inputs --- lib/hd.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/hd.ml b/lib/hd.ml index 0685413..46a7b7c 100644 --- a/lib/hd.ml +++ b/lib/hd.ml @@ -54,8 +54,11 @@ let rec decode : decoder -> decode = | false -> Angstrom.Unbuffered.Incomplete in let len = Ke.Rke.length decoder.queue in + let slice = + if len = 0 then Bigstringaf.empty + else List.hd (Ke.Rke.N.peek decoder.queue) + in if len > 0 || decoder.closed then ( - let[@warning "-8"] (slice :: _) = Ke.Rke.N.peek decoder.queue in decoder.state <- continue slice ~off:0 ~len:(Bigstringaf.length slice) more; protect decoder)