diff --git a/.gitattributes b/.gitattributes index 7e79b659e6..4521df9e43 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8325,6 +8325,7 @@ tests/webtbs/tw9179.pp svneol=native#text/plain tests/webtbs/tw9187.pp svneol=native#text/plain tests/webtbs/tw9190.pp svneol=native#text/plain tests/webtbs/tw9209.pp svneol=native#text/plain +tests/webtbs/tw9221.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 diff --git a/rtl/inc/wstrings.inc b/rtl/inc/wstrings.inc index 0259b38069..e693fd9d0a 100644 --- a/rtl/inc/wstrings.inc +++ b/rtl/inc/wstrings.inc @@ -984,9 +984,10 @@ begin end; { Force nil termination in case it gets shorter } PWord(Pointer(S)+l*sizeof(WideChar))^:=0; -{$ifndef FPC_WINLIKEWIDESTRING} - PWideRec(Pointer(S)-WideFirstOff)^.Len:=l*sizeof(WideChar); -{$endif FPC_WINLIKEWIDESTRING} +{$ifdef MSWINDOWS} + if not winwidestringalloc then +{$endif MSWINDOWS} + PWideRec(Pointer(S)-WideFirstOff)^.Len:=l*sizeof(WideChar); end else begin diff --git a/tests/webtbs/tw9221.pp b/tests/webtbs/tw9221.pp new file mode 100644 index 0000000000..916c0b32e9 --- /dev/null +++ b/tests/webtbs/tw9221.pp @@ -0,0 +1,13 @@ +{%target=win32,win64} + +var + s: widestring; +begin + winwidestringalloc:=false; + s:='1234'; + SetLength(s, 10); + if Length(s) <> 10 then begin + writeln('Test failed!'); + Halt(1); + end; +end.