Browse Source

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

git-svn-id: trunk@1961 -

Jonas Maebe 19 years ago
parent
commit
50ebeaad5e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      rtl/inc/astrings.inc

+ 4 - 2
rtl/inc/astrings.inc

@@ -463,13 +463,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;