Skip to content

Commit 11c1500

Browse files
authored
Merge pull request #69 from Morilli/fix-ub-sig
Use sigsetjmp and siglongjmp instead of setjmp and longjmp
2 parents ad1daf0 + 3f2e649 commit 11c1500

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

module.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
#endif
4444

4545
#ifndef WIN32
46-
static jmp_buf CPU_state;
46+
static sigjmp_buf CPU_state;
4747
static void seg_av_handler(int signal_code)
4848
{
49-
longjmp(CPU_state, signal_code);
49+
siglongjmp(CPU_state, signal_code);
5050
}
5151
#endif
5252
static void ISA_op_illegal(int signal_code)
@@ -522,10 +522,6 @@ void no_LLE(void)
522522
}
523523
EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, pu32 CycleCount)
524524
{
525-
#ifndef _WIN32
526-
int recovered_from_exception;
527-
#endif
528-
529525
if (CycleCount != NULL) /* cycle-accuracy not doable with today's hosts */
530526
*CycleCount = 0;
531527
update_conf(CFG_FILE);
@@ -568,7 +564,7 @@ EXPORT void CALL InitiateRSP(RSP_INFO Rsp_Info, pu32 CycleCount)
568564
#ifndef _WIN32
569565
signal(SIGSEGV, seg_av_handler);
570566
for (SR[ra] = 0; SR[ra] < 0x80000000ul; SR[ra] += 0x200000) {
571-
recovered_from_exception = setjmp(CPU_state);
567+
int recovered_from_exception = sigsetjmp(CPU_state, 1);
572568
if (recovered_from_exception)
573569
break;
574570
SR[at] += DRAM[SR[ra]];

0 commit comments

Comments
 (0)