ref: 5d7dcc27504ba2bbf19e5de635634411c85574b7
parent: 558a1777768dfecb3142c892a0564efcd7043409
author: Sebastian Rasmussen <sebras@gmail.com>
date: Tue Jul 10 22:40:57 EDT 2018
jbig2dec: Fix composing subset of image onto destination.
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -259,10 +259,29 @@
if (src == NULL)
return 0;
- if (op != JBIG2_COMPOSE_OR) {
+ /* The optimized code for the OR operator below doesn't
+ handle the source image partially placed outside the
+ destination (above and/or to the left). The affected
+ intersection of the destination is computed correctly,
+ however the correct subset of the source image is not
+ chosen. Instead the upper left corner of the source image
+ is always used.
+
+ In the unoptimized version that handles all operators
+ (including OR) the correct subset of the source image is
+ chosen.
+
+ The workaround is to check whether the x/y coordinates to
+ the composition operator are negative and in this case use
+ the unoptimized implementation.
+
+ TODO: Fix the optimized OR implementation if possible. */
+ if (op != JBIG2_COMPOSE_OR || x < 0 || y < 0) {
/* hand off the the general routine */
return jbig2_image_compose_unopt(ctx, dst, src, x, y, op);
}
+
+ /* optimized code for the prevalent OR operator */
/* clip */
w = src->width;