Skip to content

Commit

Permalink
Fix JpxImage API issues (PR 17946 follow-up)
Browse files Browse the repository at this point in the history
This commit changes the `JpxImage.decode` method signature to define the
`ignoreColorSpace` argument as optional with a default value. Note that
we already set this default value in the `getBytes` method of the
`src/core/decode_stream.js` file since this option only seems useful for
certain special cases and therefore shouldn't be mandatory to provide.

Moreover, the JPX fuzzer is changed to use the new `JpxImage` API.
  • Loading branch information
timvandermeij committed Apr 16, 2024
1 parent 801a097 commit c08b09d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JpxError extends BaseException {
class JpxImage {
static #module = null;

static decode(data, ignoreColorSpace) {
static decode(data, ignoreColorSpace = false) {
this.#module ||= OpenJPEG();
const imageData = this.#module.decode(data, ignoreColorSpace);
if (!imageData) {
Expand Down
2 changes: 1 addition & 1 deletion test/fuzz/jpx_image.fuzz.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ignoredError(error) {
*/
function fuzz(data) {
try {
new JpxImage().parse(new Uint8Array(data));
JpxImage.decode(new Uint8Array(data));
} catch (error) {
if (error.message && !ignoredError(error)) {
throw error;
Expand Down

0 comments on commit c08b09d

Please sign in to comment.