From: Carlos Montiers Date: Thu, 10 Jul 2014 04:37:20 +0000 (-0400) Subject: Fix problem using alloca function, executable crashed even with a exception handler... X-Git-Tag: release_0_9_27~870 X-Git-Url: https://repo.or.cz/w/tinycc.git/commitdiff_plain/8257829623d484229c9785deedd05375c5732493 Fix problem using alloca function, executable crashed even with a exception handler function, when try to allocate INT_MAX. Patch provided by Jason Hood in private e-mail, when I ask to him for help. He say: Feel free to pass it on to the mailing list. --- diff --git a/lib/alloca86-bt.S b/lib/alloca86-bt.S index ffad5156..ff07bbbc 100644 --- a/lib/alloca86-bt.S +++ b/lib/alloca86-bt.S @@ -14,10 +14,10 @@ __bound_alloca: #ifdef TCC_TARGET_PE p4: cmp $4096,%eax - jle p5 + jb p5 + test %eax,-4096(%esp) sub $4096,%esp sub $4096,%eax - test %eax,(%esp) jmp p4 p5: diff --git a/lib/alloca86.S b/lib/alloca86.S index b836efbf..5bb38b1f 100644 --- a/lib/alloca86.S +++ b/lib/alloca86.S @@ -13,10 +13,10 @@ alloca: #ifdef TCC_TARGET_PE p1: cmp $4096,%eax - jle p2 + jb p2 + test %eax,-4096(%esp) sub $4096,%esp sub $4096,%eax - test %eax,(%esp) jmp p1 p2: #endif diff --git a/lib/alloca86_64.S b/lib/alloca86_64.S index dd46ce6f..51acd424 100644 --- a/lib/alloca86_64.S +++ b/lib/alloca86_64.S @@ -17,10 +17,10 @@ alloca: #ifdef TCC_TARGET_PE p1: cmp $4096,%rax - jle p2 + jb p2 + test %rax,-4096(%rsp) sub $4096,%rsp sub $4096,%rax - test %rax,(%rsp) jmp p1 p2: #endif