From 1872bee116d6f68c97e447fbc26b548387c480f3 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 15 Sep 2019 17:17:30 +0000 Subject: [PATCH] * stack checking checks also proper alignment git-svn-id: trunk@43011 - --- rtl/inc/system.inc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc index c776f38057..c4cf10ff98 100644 --- a/rtl/inc/system.inc +++ b/rtl/inc/system.inc @@ -951,15 +951,25 @@ begin { Avoid recursive calls when called from the exit routines } if StackError then exit; - { don't use sack_size, since the stack pointer has already been + { check stack alignment } +{$ifdef CPUI386} +{$ifdef FPC_STACKALIGNMENT=16} + if ((PtrUInt(Sptr)+4) mod 16)<>0 then + begin + StackError:=true; + HandleError(202); + end; +{$endif FPC_STACKALIGNMENT=16} +{$endif CPUI386} + { don't use stack_size, since the stack pointer has already been decreased when this routine is called } c := Sptr - STACK_MARGIN; if (c <= StackBottom) then - begin - StackError:=true; - HandleError(202); - end; + begin + StackError:=true; + HandleError(202); + end; end; {$POP}