From d15304c25e9061b2bea00175f9d6d773ad453a26 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 19 Oct 2012 19:35:45 +0000 Subject: [PATCH] Also check for the type of the register when replacing it. In certain circumstances this can still lead to access to invalid memory resulting either in an access violation or invalid registers. git-svn-id: trunk@22779 - --- compiler/rgobj.pas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rgobj.pas b/compiler/rgobj.pas index 487fbaaa46..eaa95eeeb2 100644 --- a/compiler/rgobj.pas +++ b/compiler/rgobj.pas @@ -2259,9 +2259,12 @@ unit rgobj; begin if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then begin - { no need to check for the register type here } - tryreplacereg(ref^.base); - tryreplacereg(ref^.index); + if (ref^.base <> NR_NO) and + (getregtype(ref^.base)=regtype) then + tryreplacereg(ref^.base); + if (ref^.index <> NR_NO) and + (getregtype(ref^.index)=regtype) then + tryreplacereg(ref^.index); end; end; {$ifdef ARM}