瀏覽代碼

Use a temporary variable to avoid potential problems of overwriting the argument.

git-svn-id: trunk@33119 -
Jeppe Johansen 9 年之前
父節點
當前提交
03d4ada29e
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      rtl/arm/arm.inc

+ 5 - 3
rtl/arm/arm.inc

@@ -1130,10 +1130,12 @@ end;
   generates a perfect 4 cycle code sequence and can be inlined.
   generates a perfect 4 cycle code sequence and can be inlined.
 }
 }
 function SwapEndian(const AValue: LongWord): LongWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 function SwapEndian(const AValue: LongWord): LongWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+var
+  Temp: LongWord;
 begin
 begin
-  Result:= AValue xor rordword(AValue,16);
-  Result:= Result and $FF00FFFF;
-  Result:= (Result shr 8) xor rordword(AValue,8);
+  Temp  := AValue xor rordword(AValue,16);
+  Temp  := Temp and $FF00FFFF;
+  Result:= (Temp shr 8) xor rordword(AValue,8);
 end;
 end;
 
 
 function SwapEndian(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function SwapEndian(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}