diff --git a/TestSuite/shortstring3.pas b/TestSuite/shortstring3.pas new file mode 100644 index 000000000..fd8daf9e6 --- /dev/null +++ b/TestSuite/shortstring3.pas @@ -0,0 +1,6 @@ +begin +var s: string[1]; +var s0: string := nil; +s := s0; +assert(s = ''); +end. \ No newline at end of file diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index ec1032850..e04fa5e46 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -13677,7 +13677,9 @@ end; [System.Diagnostics.DebuggerStepThrough] function ClipShortString(s: string; len: integer): string; begin - if s.Length <= len then + if s = nil then + Result := '' + else if s.Length <= len then Result := s else Result := s.Substring(0, len); end;