* fixed crash when concatenating more than 2 ansistrings that are all empty

(mantis #25349, patch by C Western)

git-svn-id: trunk@26119 -
This commit is contained in:
Jonas Maebe 2013-11-22 12:57:41 +00:00
parent 15152a2045
commit 951727f453
3 changed files with 31 additions and 2 deletions

1
.gitattributes vendored
View File

@ -13713,6 +13713,7 @@ tests/webtbs/tw25210.pp svneol=native#text/pascal
tests/webtbs/tw2525.pp svneol=native#text/plain
tests/webtbs/tw25269.pp svneol=native#text/pascal
tests/webtbs/tw25318.pp svneol=native#text/pascal
tests/webtbs/tw25349.pp svneol=native#text/plain
tests/webtbs/tw2536.pp svneol=native#text/plain
tests/webtbs/tw2540.pp svneol=native#text/plain
tests/webtbs/tw2561.pp svneol=native#text/plain

View File

@ -314,13 +314,18 @@ begin
{$else FPC_HAS_CPSTRING}
DestCP:=StringCodePage(DestS);
{$endif FPC_HAS_CPSTRING}
DestCP:=TranslatePlaceholderCP(DestCP);
sameCP:=true;
lowstart:=low(sarr);
{ skip empty strings }
while (lowstart<=high(sarr)) and
(sarr[lowstart]='') do
inc(lowstart);
if lowstart>high(sarr) then
begin
DestS:=''; { All source strings empty }
exit;
end;
DestCP:=TranslatePlaceholderCP(DestCP);
sameCP:=true;
tmpCP:=TranslatePlaceholderCP(StringCodePage(sarr[lowstart]));
for i:=lowstart+1 to high(sarr) do
begin

23
tests/webtbs/tw25349.pp Normal file
View File

@ -0,0 +1,23 @@
procedure trashstack;
var
a: array[0..high(word)] of byte;
begin
fillchar(a,sizeof(a),$ff);
end;
procedure test;
var
s1,s2,s3,s4: ansistring;
begin
s2:='';
s3:='';
s4:='';
s1:=s2+s3+s4;
if s1<>'' then
halt(1);
end;
begin
trashstack;
test;
end.