Explorar o código

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 -
svenbarth %!s(int64=12) %!d(string=hai) anos
pai
achega
d15304c25e
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      compiler/rgobj.pas

+ 6 - 3
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}