Avoid zero division in setupPageState() function;

properly initialize array in PSDataBW().
This commit is contained in:
Andrey Kiselev 2004-08-25 13:14:18 +00:00
parent 9b6b3ab080
commit 0abad54ad0

View File

@ -1,4 +1,4 @@
/* $Id: tiff2ps.c,v 1.24 2004-08-23 13:16:54 dron Exp $ */
/* $Id: tiff2ps.c,v 1.25 2004-08-25 13:14:18 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -24,6 +24,8 @@
* OF THIS SOFTWARE.
*/
#include "tif_config.h"
#include <stdio.h>
#include <stdlib.h> /* for atof */
#include <math.h>
@ -32,6 +34,12 @@
#include "tiffio.h"
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#else
extern int getopt(int, char**, char*);
#endif
/*
* Revision history
*
@ -414,9 +422,11 @@ setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh)
/*
* Calculate printable area.
*/
if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || !xres)
if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres)
|| fabs(xres) < 0.0000001)
xres = PS_UNIT_SIZE;
if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || !yres)
if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres)
|| fabs(yres) < 0.0000001)
yres = PS_UNIT_SIZE;
switch (res_unit) {
case RESUNIT_CENTIMETER:
@ -1152,7 +1162,7 @@ int
PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h)
{
uint16 fillorder;
int use_rawdata, tiled_image, breaklen;
int use_rawdata, tiled_image, breaklen = 0;
uint32 chunk_no, num_chunks, *bc;
unsigned char *buf_data, *cp;
tsize_t chunk_size, byte_count;
@ -1608,6 +1618,7 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
(void) w; (void) h;
tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
memset(tf_buf, 0, stripsize);
if (tf_buf == NULL) {
TIFFError(filename, "No space for scanline buffer");
return;