From 096ebb6c591339705cca03d4cb7ad6f0bd245d26 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 3 Dec 2022 14:18:12 +0200 Subject: [PATCH] debugmem stack frame tracker overflow check --- debugmem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/debugmem.cpp b/debugmem.cpp index a182ff86..ac15b80e 100644 --- a/debugmem.cpp +++ b/debugmem.cpp @@ -512,13 +512,21 @@ void branch_stack_pop_rts(uaecptr oldpc) void branch_stack_push(uaecptr oldpc, uaecptr newpc) { - if (!stackframes) + if (!stackframes) { return; + } if (!stackframemode) { - if (debug_waiting || (!regs.s && get_long_host(exec_thistask) != debug_task)) + if (debug_waiting || (!regs.s && get_long_host(exec_thistask) != debug_task)) { return; + } } int cnt = regs.s ? stackframecntsuper : stackframecnt; + if (cnt >= MAX_STACKFRAMES) { + write_log(_T("Stack frame %c max limit reached!\n"), regs.s ? 'S' : 'U'); + stackframecntsuper = 0; + stackframecnt = 0; + return; + } struct debugstackframe *sf = regs.s ? &stackframessuper[cnt] : &stackframes[cnt]; sf->current_pc = regs.instruction_pc; sf->next_pc = newpc; -- 2.47.3