Skip to content

Commit cd32989

Browse files
committed
also protect entry
1 parent 6d60a12 commit cd32989

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/wasm/wasm_exec.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,19 +545,16 @@
545545
throw new Error("total length of command line and environment variables exceeds limit");
546546
}
547547

548-
this._inst.exports.run(argc, argv);
548+
this._runCatch(() => this._inst.exports.run(argc, argv));
549549
if (this.exited) {
550550
this._resolveExitPromise();
551551
}
552552
await this._exitPromise;
553553
}
554554

555-
_resume() {
556-
if (this.exited) {
557-
throw new Error("Go program has already exited");
558-
}
555+
_runCatch(fn) {
559556
try {
560-
this._inst.exports.resume();
557+
fn();
561558
} catch (err) {
562559
if (err instanceof RangeError) {
563560
// runtime.throw
@@ -567,6 +564,15 @@
567564
throw err;
568565
}
569566
}
567+
}
568+
569+
_resume() {
570+
if (this.exited) {
571+
throw new Error("Go program has already exited");
572+
}
573+
574+
this._runCatch(() => this._inst.exports.resume());
575+
570576
if (this.exited) {
571577
this._resolveExitPromise();
572578
}

0 commit comments

Comments
 (0)