summaryrefslogtreecommitdiff
path: root/jbig2dec/jbig2_image.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-02-28 17:36:00 +0000
committerRobin Watts <robin.watts@artifex.com>2017-03-01 17:26:34 +0000
commitf8c0d4e78f75de95b0d74210b3e929abef6f3a60 (patch)
tree3ccbf148ad669ba1b1c178ec4138f87190b47f16 /jbig2dec/jbig2_image.c
parentbbb2b961388b028d7d9d8f6454ced8192ad513c1 (diff)
downloadghostpdl-f8c0d4e78f75de95b0d74210b3e929abef6f3a60.tar.gz
Add sanity check on image sizes.
Inspired by bug 697395, but doesn't actually solve any problem seen in that bug (or at least, not that I can see, as I can't reproduce the problem with file2).
Diffstat (limited to 'jbig2dec/jbig2_image.c')
-rw-r--r--jbig2dec/jbig2_image.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/jbig2dec/jbig2_image.c b/jbig2dec/jbig2_image.c
index 00f966b4c..661d0a5a7 100644
--- a/jbig2dec/jbig2_image.c
+++ b/jbig2dec/jbig2_image.c
@@ -38,6 +38,13 @@ jbig2_image_new(Jbig2Ctx *ctx, uint32_t width, uint32_t height)
uint32_t stride;
int64_t check;
+ if (width == 0 || height == 0) {
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1,
+ "zero width (%d) or height (%d) in jbig2_image_new",
+ width, height);
+ return NULL;
+ }
+
image = jbig2_new(ctx, Jbig2Image, 1);
if (image == NULL) {
jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "could not allocate image structure in jbig2_image_new");