From: Yann Collet Date: Sun, 18 Sep 2016 10:17:51 +0000 (+0200) Subject: streaming compression example can handle situations where input buffer size is manual... X-Git-Tag: v1.1.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ca3d4bc252177aa99fa9fedacb33c0c4aee63fc;p=thirdparty%2Fzstd.git streaming compression example can handle situations where input buffer size is manually set to a small value. --- 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); } }