Skip to content

Commit d9b81b5

Browse files
Merge pull request #20818 from Snuffleupagus/JBig2-fixes
A couple of small JBig2 fixes
2 parents 99f1109 + efa13c5 commit d9b81b5

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/core/cleanup_helper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
import { clearPatternCaches } from "./pattern.js";
1717
import { clearPrimitiveCaches } from "./primitives.js";
1818
import { clearUnicodeCaches } from "./unicode.js";
19+
import { JBig2CCITTFaxWasmImage } from "./jbig2_ccittFax_wasm.js";
1920
import { JpxImage } from "./jpx.js";
2021

2122
function clearGlobalCaches() {
2223
clearPatternCaches();
2324
clearPrimitiveCaches();
2425
clearUnicodeCaches();
2526

26-
// Remove the global `JpxImage` instance, since it may hold a reference to
27-
// the WebAssembly module.
27+
// Remove the global `JBig2CCITTFaxWasmImage`/`JpxImage` instances,
28+
// since they may hold references to the WebAssembly modules.
29+
JBig2CCITTFaxWasmImage.cleanup();
2830
JpxImage.cleanup();
2931
}
3032

src/core/jbig2_ccittFax_wasm.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { BaseException, warn } from "../shared/util.js";
1716
import { fetchBinaryData } from "./core_utils.js";
1817
import JBig2 from "../../external/jbig2/jbig2.js";
19-
20-
class JBig2Error extends BaseException {
21-
constructor(msg) {
22-
super(msg, "Jbig2Error");
23-
}
24-
}
18+
import { Jbig2Error } from "./jbig2.js";
19+
import { warn } from "../shared/util.js";
2520

2621
class JBig2CCITTFaxWasmImage {
2722
static #buffer = null;
@@ -87,7 +82,7 @@ class JBig2CCITTFaxWasmImage {
8782
}
8883
const module = await this.#modulePromise;
8984
if (!module) {
90-
throw new JBig2Error("JBig2 failed to initialize");
85+
throw new Jbig2Error("JBig2 failed to initialize");
9186
}
9287
let ptr, globalsPtr;
9388

@@ -118,7 +113,7 @@ class JBig2CCITTFaxWasmImage {
118113
module._jbig2_decode(ptr, size, width, height, globalsPtr, globalsSize);
119114
}
120115
if (!module.imageData) {
121-
throw new JBig2Error("Unknown error");
116+
throw new Jbig2Error("Unknown error");
122117
}
123118
const { imageData } = module;
124119
module.imageData = null;
@@ -139,4 +134,4 @@ class JBig2CCITTFaxWasmImage {
139134
}
140135
}
141136

142-
export { JBig2CCITTFaxWasmImage, JBig2Error };
137+
export { JBig2CCITTFaxWasmImage };

0 commit comments

Comments
 (0)