From baa0d8f46983026c7d5c63df1ce5101f9f0e7e97 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 10 Oct 2010 17:07:55 -0300 Subject: [PATCH] Fix __builtin_return_address() for MSVC (problems accessing to the address pointed by eax when it is too small). --- src/gui/jmem.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/jmem.cpp b/src/gui/jmem.cpp index 877d53f99..9024eb5cf 100644 --- a/src/gui/jmem.cpp +++ b/src/gui/jmem.cpp @@ -76,17 +76,20 @@ __declspec (naked) void* __builtin_return_address(int level) push ebx mov eax, ebp - mov ebx, DWORD PTR [esp + 8] // level + mov ebx, DWORD PTR[esp+8] __next: test ebx, ebx je __break dec ebx - mov eax, DWORD PTR [eax] - test eax, eax - je __done + mov eax, DWORD PTR[eax] + cmp eax, 0xffff + jbe __outofstack jmp __next +__outofstack: + mov eax, 0 + jmp __done __break: - mov eax, DWORD PTR [eax + 4] + mov eax, DWORD PTR[eax+4] __done: pop ebx ret