From 7d7b3db2705ca78f0963734ab5a5e4671c7762bb Mon Sep 17 00:00:00 2001 From: Bob Friesenhahn Date: Sun, 31 May 2015 21:24:44 +0000 Subject: [PATCH] (LogLuvEncodeTile): Fix Coverity 991241 "Division or modulo by zero". --- ChangeLog | 2 ++ libtiff/tif_luv.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1de8f91f..ed0b1c7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ zero". (LogLuvEncodeStrip): Fix Coverity 991240 "Division or modulo by zero". + (LogLuvEncodeTile): Fix Coverity 991241 "Division or modulo by + zero". * libtiff/tif_dirread.c (TIFFReadDirEntryDoubleArray): Fix Coverity 298626 "Logically dead code". diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index 37193742..d2952a8a 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.38 2015-05-31 21:23:23 bfriesen Exp $ */ +/* $Id: tif_luv.c,v 1.39 2015-05-31 21:24:44 bfriesen Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -668,6 +668,9 @@ LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { tmsize_t rowlen = TIFFTileRowSize(tif); + if (rowlen == 0) + return 0; + assert(cc%rowlen == 0); while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) bp += rowlen, cc -= rowlen;