Skip to content

Commit

Permalink
Update the current stride before composing when decoding a text region
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Apr 3, 2024
1 parent 1031210 commit 18b284c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/core/jbig2.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,22 @@ function decodeTextRegion(
decodingContext
);
}

let increment = 0;
if (!transposed) {
if (referenceCorner > 1) {
currentS += symbolWidth - 1;
} else {
increment = symbolWidth - 1;
}
} else if (transposed) {

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'transposed' always evaluates to true.
if (!(referenceCorner & 1)) {
currentS += symbolHeight - 1;
} else {
increment = symbolHeight - 1;
}
}

const offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
const offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
let s2, t2, symbolRow;
Expand Down Expand Up @@ -896,7 +912,6 @@ function decodeTextRegion(
);
}
}
currentS += symbolHeight - 1;
} else {
for (t2 = 0; t2 < symbolHeight; t2++) {
row = bitmap[offsetT + t2];
Expand All @@ -921,7 +936,6 @@ function decodeTextRegion(
);
}
}
currentS += symbolWidth - 1;
}
i++;
const deltaS = huffman
Expand All @@ -930,7 +944,7 @@ function decodeTextRegion(
if (deltaS === null) {
break; // OOB
}
currentS += deltaS + dsOffset;
currentS += increment + deltaS + dsOffset;
} while (true);
}
return bitmap;
Expand Down
2 changes: 2 additions & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,5 @@
!bug1868759.pdf
!issue17730.pdf
!bug1883609.pdf
!issue17871_bottom_right.pdf
!issue17871_top_right.pdf
Binary file added test/pdfs/issue17871_bottom_right.pdf
Binary file not shown.
Binary file added test/pdfs/issue17871_top_right.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9794,5 +9794,19 @@
"rounds": 1,
"link": true,
"type": "other"
},
{
"id": "issue17871_bottom_right",
"file": "pdfs/issue17871_bottom_right.pdf",
"md5": "664807166c5279224abfbf259f701958",
"rounds": 1,
"type": "eq"
},
{
"id": "issue17871_top_right",
"file": "pdfs/issue17871_top_right.pdf",
"md5": "07d95eabf18aee0cf38f09eb7b1390ec",
"rounds": 1,
"type": "eq"
}
]

0 comments on commit 18b284c

Please sign in to comment.