From 4ca3d4bc252177aa99fa9fedacb33c0c4aee63fc Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sun, 18 Sep 2016 12:17:51 +0200 Subject: [PATCH] streaming compression example can handle situations where input buffer size is manually set to a small value. --- examples/streaming_compression.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/streaming_compression.c b/examples/streaming_compression.c index bc81af1a3..d663a4914 100644 --- a/examples/streaming_compression.c +++ b/examples/streaming_compression.c @@ -81,6 +81,7 @@ static void compressFile_orDie(const char* fname, const char* outName, int cLeve while (input.pos < input.size) { ZSTD_outBuffer output = { buffOut, buffOutSize, 0 }; toRead = ZSTD_compressStream(cstream, &output , &input); /* toRead is guaranteed to be <= ZSTD_CStreamInSize() */ + if (toRead > buffInSize) toRead = buffInSize; /* Safely handle when `buffInSize` is manually changed to a smaller value */ fwrite_orDie(buffOut, output.pos, fout); } }