Parcourir la source

Merged revisions 1961 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

r1961 (jonas)
* fixed fpc_ansistr_append_ansistring() in case it's called to append a
string to itself

git-svn-id: branches/fixes_2_0@1970 -

Jonas Maebe il y a 20 ans
Parent
commit
f7518a764b
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 4 2
      rtl/inc/astrings.inc

+ 4 - 2
rtl/inc/astrings.inc

@@ -459,13 +459,15 @@ end;
 
 Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;const Str : AnsiString); [Public,Alias : 'FPC_ANSISTR_APPEND_ANSISTRING']; compilerproc;
 var
-   ofs : SizeInt;
+   ofs, strlength : SizeInt;
 begin
    if Str='' then
      exit;
+   { needed in case s and str are the same string }
+   strlength := length(str);
    ofs:=Length(S);
    SetLength(S,ofs+length(Str));
-   move(Str[1],S[ofs+1],length(Str)+1);
+   move(Str[1],S[ofs+1],strlength+1);
 end;
 
 Function Fpc_Ansistr_Copy (Const S : AnsiString; Index,Size : SizeInt) : AnsiString;compilerproc;