diff --git a/.gitattributes b/.gitattributes index 5d88c7bf90..a02555a8a1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index 3d76a04b22..bbcf5dd52d 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -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 diff --git a/tests/webtbs/tw25349.pp b/tests/webtbs/tw25349.pp new file mode 100644 index 0000000000..13a83d407a --- /dev/null +++ b/tests/webtbs/tw25349.pp @@ -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.