Zero division problem fixed (Vladimir Nadvornik, Dmitry V. Levin).

This commit is contained in:
Andrey Kiselev 2004-10-26 18:17:19 +00:00
parent 3de1b05f13
commit 7a8b7651cd
2 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_strip.c,v 1.12 2004-10-02 11:16:27 dron Exp $ */
/* $Id: tif_strip.c,v 1.13 2004-10-26 18:17:19 dron Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -128,10 +128,15 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
ycbcrsubsampling + 0,
ycbcrsubsampling + 1 );
samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1];
if (samplingarea == 0) {
TIFFError(tif->tif_name, "Invalid YCbCr subsampling");
return 0;
}
w = TIFFroundup(td->td_imagewidth, ycbcrsubsampling[0]);
scanline = TIFFhowmany8(multiply(tif, w, td->td_bitspersample,
"TIFFVStripSize"));
samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1];
nrows = TIFFroundup(nrows, ycbcrsubsampling[1]);
/* NB: don't need TIFFhowmany here 'cuz everything is rounded */
scanline = multiply(tif, nrows, scanline, "TIFFVStripSize");

View File

@ -1,4 +1,4 @@
/* $Id: tif_tile.c,v 1.8 2004-10-02 11:16:27 dron Exp $ */
/* $Id: tif_tile.c,v 1.9 2004-10-26 18:17:19 dron Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -208,6 +208,10 @@ TIFFVTileSize(TIFF* tif, uint32 nrows)
"TIFFVTileSize"));
tsize_t samplingarea =
td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1];
if (samplingarea == 0) {
TIFFError(tif->tif_name, "Invalid YCbCr subsampling");
return 0;
}
nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]);
/* NB: don't need TIFFhowmany here 'cuz everything is rounded */
tilesize = multiply(tif, nrows, rowsize, "TIFFVTileSize");