Skip to content

Commit edbdbef

Browse files
committed
GH-79 Fix LONGJMP() from functions so they return through THROW
when a CATCH frame is defined.
1 parent 110b9aa commit edbdbef

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/post4.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,10 +1339,11 @@ p4Repl(P4_Ctx *ctx, int thrown)
13391339

13401340
SETJMP_PUSH(ctx->longjmp);
13411341
rc = SETJMP(ctx->longjmp);
1342-
1343-
if (thrown) {
1342+
if (thrown != P4_THROW_OK) {
13441343
/* Signal thrown overrides context. */
13451344
rc = thrown;
1345+
}
1346+
if (ctx->frame != NULL) {
13461347
/* Throw might be caught, can't fall through. */
13471348
THROW(rc);
13481349
}

src/post4.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,16 @@ struct p4_ctx {
433433
P4_Char * end; /* End of data space memory. */
434434
P4_Char * here; /* Next unused data space. */
435435
P4_Int state;
436-
P4_Int frame; /* See CATCH and THROW. */
436+
P4_Cell * frame; /* See CATCH and THROW. */
437437
P4_Int trace; /* Word trace for debugging. */
438438
P4_Int level; /* Tracing depth. */
439439
P4_Uint radix; /* Input/Output radix */
440440
P4_Stack ds; /* Data stack */
441441
P4_Stack rs; /* Return stack */
442-
/* #ifdef HAVE_MATH_H */
442+
/* Leave these in place even if float support is disabled. */
443443
P4_Stack fs; /* Float stack */
444444
P4_Int precision;
445-
/* #endif */
445+
/* ... */
446446
P4_Int unkey; /* KEY and KEY? */
447447
P4_Input * input;
448448
P4_Block * block;
@@ -453,9 +453,9 @@ struct p4_ctx {
453453
P4_Uint norder; /* Order length, [0, P4_WORDLISTS) */
454454
P4_Uint order[P4_WORDLISTS];
455455
P4_Options * options;
456-
/* #ifdef WITH_JAVA */
456+
/* Leave this in place even if JNI support is disabled. */
457457
void * jenv;
458-
/* #endif */
458+
/* ... */
459459
JMP_BUF longjmp; /* Must be last in struct; size can
460460
* vary by CPU and implementation.
461461
*/

0 commit comments

Comments
 (0)