mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-17 21:32:30 +02:00
* fixed another bug in fpc_ansistr_append_ansistring in case source = dest
(web bug #4999) git-svn-id: trunk@3185 -
This commit is contained in:
parent
039e7143f4
commit
72b75a627a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6779,6 +6779,7 @@ tests/webtbs/tw4898.pp -text
|
||||
tests/webtbs/tw4902.pp -text
|
||||
tests/webtbs/tw4922.pp svneol=native#text/plain
|
||||
tests/webtbs/tw4950.pp svneol=native#text/plain
|
||||
tests/webtbs/tw4999.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||
|
@ -503,16 +503,22 @@ end;
|
||||
|
||||
Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;const Str : AnsiString); [Public,Alias : 'FPC_ANSISTR_APPEND_ANSISTRING']; compilerproc;
|
||||
var
|
||||
ofs, strlength : SizeInt;
|
||||
ofs, strlength: SizeInt;
|
||||
samestring: boolean;
|
||||
begin
|
||||
if Str='' then
|
||||
exit;
|
||||
samestring := pointer(s) = pointer(str);
|
||||
{ needed in case s and str are the same string }
|
||||
strlength := length(str);
|
||||
ofs:=Length(S);
|
||||
SetLength(S,ofs+strlength);
|
||||
{ the pbyte cast avoids an unique call which isn't necessary because SetLength was just called }
|
||||
move(Str[1],(pointer(S)+ofs)^,strlength+1);
|
||||
if not(samestring) then
|
||||
move(Str[1],(pointer(S)+ofs)^,strlength+1)
|
||||
else
|
||||
{ the setlength may have relocated the string, so str may no longer be valid }
|
||||
move(S[1],(pointer(S)+ofs)^,strlength+1)
|
||||
end;
|
||||
|
||||
Function Fpc_Ansistr_Copy (Const S : AnsiString; Index,Size : SizeInt) : AnsiString;compilerproc;
|
||||
|
12
tests/webtbs/tw4999.pp
Normal file
12
tests/webtbs/tw4999.pp
Normal file
@ -0,0 +1,12 @@
|
||||
program fpc203fish;
|
||||
{$mode objfpc}{$H+}
|
||||
uses Classes;
|
||||
var s:String;
|
||||
i:integer;
|
||||
begin
|
||||
s:='123123sdfjkysdjfklsdn3m,w45';
|
||||
for i:=0 to 22 do begin
|
||||
s:=s+s;
|
||||
writeln(i);
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user