aboutsummaryrefslogtreecommitdiff
path: root/c/dec/decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/dec/decode.c')
-rw-r--r--c/dec/decode.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/c/dec/decode.c b/c/dec/decode.c
index fe8af63..de46eb4 100644
--- a/c/dec/decode.c
+++ b/c/dec/decode.c
@@ -116,6 +116,10 @@ static BROTLI_NOINLINE BrotliDecoderResult SaveErrorCode(
BrotliDecoderState* s, BrotliDecoderErrorCode e, size_t consumed_input) {
s->error_code = (int)e;
s->used_input += consumed_input;
+ if ((s->buffer_length != 0) && (s->br.next_in == s->br.last_in)) {
+ /* If internal buffer is depleted at last, reset it. */
+ s->buffer_length = 0;
+ }
switch (e) {
case BROTLI_DECODER_SUCCESS:
return BROTLI_DECODER_RESULT_SUCCESS;
@@ -2351,6 +2355,7 @@ BrotliDecoderResult BrotliDecoderDecompressStream(
/* Not enough data in buffer, but can take one more byte from
input stream. */
result = BROTLI_DECODER_SUCCESS;
+ BROTLI_DCHECK(s->buffer_length < 8);
s->buffer.u8[s->buffer_length] = **next_in;
s->buffer_length++;
BrotliBitReaderSetInput(br, &s->buffer.u8[0], s->buffer_length);