Index: third_party/brotli/dec/streams.c |
diff --git a/third_party/brotli/dec/streams.c b/third_party/brotli/dec/streams.c |
index 623d417cf4c7100ff7d1303fb403944b4888784c..b33f7a46e9e26ad20f51fb1b2f40bdbc6b0a9b45 100644 |
--- a/third_party/brotli/dec/streams.c |
+++ b/third_party/brotli/dec/streams.c |
@@ -51,8 +51,9 @@ BrotliInput BrotliInitMemInput(const uint8_t* buffer, size_t length, |
int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count) { |
BrotliMemOutput* output = (BrotliMemOutput*)data; |
- if (output->pos + count > output->length) { |
- return -1; |
+ size_t limit = output->length - output->pos; |
+ if (count > limit) { |
+ count = limit; |
} |
memcpy(output->buffer + output->pos, buf, count); |
output->pos += count; |