Skip to content

Commit 3926373

Browse files
committed
fix longjmp(,0)
1 parent 9e3e24e commit 3926373

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wasm/longjmp/rt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ __wasm_longjmp(void *env, int val)
8484
{
8585
struct state *state = &g_state;
8686
struct arg *arg = &state->arg;
87+
/*
88+
* C standard:
89+
* > The longjmp function cannot cause the setjmp macro to return
90+
* > the value 0; if val is 0, the setjmp macro returns the value 1.
91+
*/
92+
if (val == 0) {
93+
val = 1;
94+
}
8795
arg->env = env;
8896
arg->val = val;
8997
__builtin_wasm_throw(1, arg);

0 commit comments

Comments
 (0)