forked from lix-project/lix
Merge "BrotliDecompressionSource: don't bail out too early" into main
This commit is contained in:
commit
697ef65c14
|
@ -163,12 +163,15 @@ struct BrotliDecompressionSource : Source
|
|||
uint8_t * out = (uint8_t *) data;
|
||||
const auto * begin = out;
|
||||
|
||||
try {
|
||||
while (len && !BrotliDecoderIsFinished(state.get())) {
|
||||
checkInterrupt();
|
||||
|
||||
while (avail_in == 0) {
|
||||
try {
|
||||
avail_in = inner->read(buf.get(), BUF_SIZE);
|
||||
} catch (EndOfFile &) {
|
||||
break;
|
||||
}
|
||||
next_in = (const uint8_t *) buf.get();
|
||||
}
|
||||
|
||||
|
@ -179,8 +182,6 @@ struct BrotliDecompressionSource : Source
|
|||
throw CompressionError("error while decompressing brotli file");
|
||||
}
|
||||
}
|
||||
} catch (EndOfFile &) {
|
||||
}
|
||||
|
||||
if (begin != out) {
|
||||
return out - begin;
|
||||
|
|
|
@ -66,6 +66,16 @@ namespace nix {
|
|||
ASSERT_THROW(decompress(method, str), CompressionError);
|
||||
}
|
||||
|
||||
TEST(decompress, veryLongBrotli) {
|
||||
auto method = "br";
|
||||
auto str = std::string(65536, 'a');
|
||||
auto o = decompress(method, compress(method, str));
|
||||
|
||||
// This is just to not print 64k of "a" for most failures
|
||||
ASSERT_EQ(o.length(), str.length());
|
||||
ASSERT_EQ(o, str);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* compression sinks
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue