From 8dbb7ea40a1887bcbc2ef9bdab97dad968f4002d Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 9 Jan 2025 11:06:31 +0000 Subject: [PATCH] Fix size of buffer for backtrace --- Source/NSException.m | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/NSException.m b/Source/NSException.m index eb44878c3..4c525e16a 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -593,16 +593,21 @@ struct GSBacktraceState static _Unwind_Reason_Code GSUnwindCallback(struct _Unwind_Context* context, void* arg) { - struct GSBacktraceState *state = (struct GSBacktraceState*)arg; - uintptr_t pc = _Unwind_GetIP(context); - if (pc) { - if (state->current == state->end) { - return _URC_END_OF_STACK; - } else { - *state->current++ = (void*)pc; - } + struct GSBacktraceState *state = (struct GSBacktraceState*)arg; + uintptr_t pc = _Unwind_GetIP(context); + + if (pc) + { + if (state->current == state->end) + { + return _URC_END_OF_STACK; + } + else + { + *state->current++ = (void*)pc; + } } - return 0; //_URC_OK/_URC_NO_REASON + return 0; //_URC_OK/_URC_NO_REASON } #endif /* WITH_UNWIND && !HAVE_BACKTRACE */ @@ -994,7 +999,7 @@ GSPrivateReturnAddresses(NSUInteger **returns) GS_MUTEX_UNLOCK(traceLock); #elif defined(HAVE_BACKTRACE) - void *addr[MAXFRAMES*sizeof(NSUInteger)]; + void *addr[MAXFRAMES]; numReturns = backtrace(addr, MAXFRAMES); if (numReturns > 0)