From 010a2645071fcf4546c20d12ee3530a7063a05cc Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Wed, 23 Feb 2011 21:57:59 +0000 Subject: [PATCH] avoid divide by zero in degenerate case (#2296) --- ChangeLog | 2 ++ libtiff/tif_jpeg.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2d839ff4..354dbc06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2011-02-23 Frank Warmerdam + * libtiff/tif_jpeg.c: avoid divide by zero in degenerate case (#2296) + * tools/tiff2rgba.c: close source file on error to make leak detection easier. diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index 05aae9cd..b59c6301 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.100 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_jpeg.c,v 1.101 2011-02-23 21:58:00 fwarmerdam Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -1215,6 +1215,9 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) */ sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; + + if( sp->bytesperline == 0 ) + return 0; nrows = cc / sp->bytesperline; if (cc % sp->bytesperline)