From 7aa6cec9300c8a3e9ef98b19791ad324d487512e Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Sun, 8 Mar 2026 02:27:14 +0000 Subject: New upstream version 6.0.25.33+repack --- CommonCode.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'CommonCode.c') diff --git a/CommonCode.c b/CommonCode.c index 26dda97..eb6c011 100644 --- a/CommonCode.c +++ b/CommonCode.c @@ -395,16 +395,54 @@ BOK1: return 0; } + +void CheckFreeQueue(char * File, int Line) +{ + void ** pointer; + int n = 0; + void ** debug; + PMESSAGE Test; + + pointer = FREE_Q; + debug = &FREE_Q; + + while (pointer) + { + // Validate pointer to make sure it is in pool - it may be a duff address if Q is corrupt + + Test = (PMESSAGE)pointer; + + if (Test->GuardZone || (uintptr_t)pointer < (uintptr_t)BUFFERPOOL || (uintptr_t)pointer > (uintptr_t)ENDBUFFERPOOL) + { + // Not pointing to a buffer . debug points to the buffer that this is chained from + + Debugprintf("CheckFree Queue Pool Corruption n = %d, ptr %p prev %p from %s Line %d", n, pointer, debug, File, Line); + } + + debug = pointer; + pointer = pointer[0]; + n++; + + if (n > 1000) + { + Debugprintf("CheckFreeQueue Loop searching free chain - pointer = %p %p from %s Line %d", debug, pointer, File, Line); + FindLostBuffers(); + WriteMiniDump(); + Restart(); + } + } +} + int _C_Q_ADD(VOID *PQ, VOID *PBUFF, char * File, int Line) { void ** Q; void ** BUFF = PBUFF; void ** next; PMESSAGE Test; - - int n = 0; + CheckFreeQueue(File, Line); + // PQ may not be word aligned, so copy as bytes (for ARM5) Q = PQ; @@ -532,6 +570,8 @@ VOID * _GetBuff(char * File, int Line) char * fptr = 0; unsigned char * byteaddr; + CheckFreeQueue(File, Line); + Temp = Q_REM(&FREE_Q); // FindLostBuffers(); -- cgit v1.2.3