[gs-commits] mupdf 1.16.1.60 Avoid signedness issues in fz_image.

[email protected] (Sebastian Rasmussen) Tue, 1 Oct 2019 14:55:51 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
commit a0eda1af9e0f7efa6eef469a8e4d8c133de88be4
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Sep 27 17:52:47 2019 +0200

    Avoid signedness issues in fz_image.

diff --git a/include/mupdf/fitz/image.h b/include/mupdf/fitz/image.h
index 9666deb..4b4af4a 100644
--- a/include/mupdf/fitz/image.h
+++ b/include/mupdf/fitz/image.h
@@ -79,7 +79,7 @@ fz_image *fz_new_image_of_size(fz_context *ctx,
 		float *decode,
 		int *colorkey,
 		fz_image *mask,
-		int size,
+		size_t size,
 		fz_image_get_pixmap_fn *get_pixmap,
 		fz_image_get_size_fn *get_size,
 		fz_drop_image_fn *drop);
diff --git a/source/fitz/image.c b/source/fitz/image.c
index eb60aac..074cdfc 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -369,7 +369,7 @@ fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image
 			tile->flags &= ~FZ_PIXMAP_FLAG_INTERPOLATE;
 
 		stride = (w * image->n * image->bpc + 7) / 8;
-		if (h > SIZE_MAX / stride)
+		if ((size_t)h > (size_t)(SIZE_MAX / stride))
 			fz_throw(ctx, FZ_ERROR_MEMORY, "image too large");
 		samples = fz_malloc(ctx, h * stride);
 
@@ -935,7 +935,7 @@ fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask)
 fz_image *
 fz_new_image_of_size(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace,
 		int xres, int yres, int interpolate, int imagemask, float *decode,
-		int *colorkey, fz_image *mask, int size,
+		int *colorkey, fz_image *mask, size_t size,
 		fz_image_get_pixmap_fn *get_pixmap,
 		fz_image_get_size_fn *get_size,
 		fz_drop_image_fn *drop)

http://git.ghostscript.com/?p=mupdf.git;a=commit;h=a0eda1af9e0f7efa6eef469a8e4d8c133de88be4

--
MuPDF library
Artifex Software, Inc.