From e512b6ccb6937f3851811ba6ba7343f9461c49e0 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 29 May 2019 13:43:40 -0700 Subject: [PATCH] panic if stuck in a CONTINUATION frame write loop --- src/codec/framed_write.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/codec/framed_write.rs b/src/codec/framed_write.rs index 504e0c5..87ebc67 100644 --- a/src/codec/framed_write.rs +++ b/src/codec/framed_write.rs @@ -197,6 +197,17 @@ where Some(Next::Continuation(frame)) => { // Buffer the continuation frame, then try to write again if let Some(continuation) = frame.encode(&mut self.hpack, self.buf.get_mut()) { + + // We previously had a CONTINUATION, and after encoding + // it, we got *another* one? Let's just double check + // that at least some progress is being made... + if self.buf.get_ref().len() == frame::HEADER_LEN { + // If *only* the CONTINUATION frame header was + // written, and *no* header fields, we're stuck + // in a loop... + panic!("CONTINUATION frame write loop; header value too big to encode"); + } + self.next = Some(Next::Continuation(continuation)); } },