summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2015-04-16 12:18:15 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2015-04-16 12:18:15 (GMT)
commit2ed9dcc900a8a662a52d11968baf27f61a9bedd3 (patch)
tree031f35a697d5e6e106b979a06222a74330f3cb69 /programs/lz4io.c
parent633c1ca810cb18f9e61f9cd4d90ad104305a0505 (diff)
downloadlz4-2ed9dcc900a8a662a52d11968baf27f61a9bedd3.zip
lz4-2ed9dcc900a8a662a52d11968baf27f61a9bedd3.tar.gz
lz4-2ed9dcc900a8a662a52d11968baf27f61a9bedd3.tar.bz2
fix minor "divide by zero" risk
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 258af5b..e2f2801 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -487,7 +487,8 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
size_t cSize = LZ4F_compressFrame(dstBuffer, dstBufferSize, srcBuffer, readSize, &prefs);
if (LZ4F_isError(cSize)) EXM_THROW(34, "Compression failed : %s", LZ4F_getErrorName(cSize));
compressedfilesize += cSize;
- DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ", (unsigned)(filesize>>20), (double)compressedfilesize/filesize*100);
+ DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ",
+ (unsigned)(filesize>>20), (double)compressedfilesize/(filesize+!filesize)*100); /* avoid division by zero */
/* Write Block */
sizeCheck = fwrite(dstBuffer, 1, cSize, dstFile);