summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2019-06-14 03:27:31 +0200
committerSebastian Rasmussen <sebras@gmail.com>2019-09-05 03:27:29 +0200
commit49a6ff2b166a4cda4d7b8c9d8192bb6f419c7ca3 (patch)
treed1edf7cdcb2523ee470e44e51df46234f11cf4c7
parent8719833a6a4242880ad8b81cb8fe19e03667af52 (diff)
downloadghostpdl-49a6ff2b166a4cda4d7b8c9d8192bb6f419c7ca3.tar.gz
Bug 701197: jbig2dec: Fix incorrectly computed halftone skip mask.
Halftone regions using a skip mask and negative horizontal grid origin offsets caused issues due to multiplying signed and unsigned integers. The mixed types expression was computed unsigned unsigned arithmetic before being converted back to a signed integer. This meant that an expected negative value became positive. Several of the test files mentioned in the README rendered incorrectly, e.g. 200-6-45.jb2. With this fix all files render correctly again.
-rw-r--r--jbig2dec/jbig2_halftone.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/jbig2dec/jbig2_halftone.c b/jbig2dec/jbig2_halftone.c
index 8a18fc70b..69bd21ebc 100644
--- a/jbig2dec/jbig2_halftone.c
+++ b/jbig2dec/jbig2_halftone.c
@@ -458,7 +458,7 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
Jbig2Image *HSKIP = NULL;
Jbig2PatternDict *HPATS;
uint32_t i;
- uint32_t mg, ng;
+ int32_t mg, ng;
int32_t x, y;
uint16_t gray_val;
int code = 0;
@@ -481,8 +481,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
for (mg = 0; mg < params->HGH; ++mg) {
for (ng = 0; ng < params->HGW; ++ng) {
- x = (params->HGX + mg * (int32_t) params->HRY + ng * (int32_t) params->HRX) >> 8;
- y = (params->HGY + mg * (int32_t) params->HRX - ng * (int32_t) params->HRY) >> 8;
+ x = (params->HGX + mg * params->HRY + ng * params->HRX) >> 8;
+ y = (params->HGY + mg * params->HRX - ng * params->HRY) >> 8;
if (x + HPATS->HPW <= 0 || x >= (int32_t) image->width || y + HPATS->HPH <= 0 || y >= (int32_t) image->height) {
jbig2_image_set_pixel(HSKIP, ng, mg, 1);