瀏覽代碼

* Fixed r44960. Also copy a trailing implicit #0 of the original string to the new larger string.

git-svn-id: trunk@44970 -
yury 5 年之前
父節點
當前提交
c3954a0cee
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      rtl/inc/astrings.inc

+ 6 - 2
rtl/inc/astrings.inc

@@ -798,8 +798,12 @@ begin
           Temp:=NewAnsiString(L);
           Temp:=NewAnsiString(L);
           PAnsiRec(Pointer(Temp)-AnsiFirstOff)^.CodePage:=PAnsiRec(Pointer(S)-AnsiFirstOff)^.CodePage;
           PAnsiRec(Pointer(Temp)-AnsiFirstOff)^.CodePage:=PAnsiRec(Pointer(S)-AnsiFirstOff)^.CodePage;
           lens:=length(s);
           lens:=length(s);
-          if l<lens then
-            lens:=l;
+          if l<=lens then
+            lens:=l
+          else
+            { Also copy a trailing implicit #0 of the original string
+              to the new larger string }
+            Inc(lens);
           Move(Pointer(S)^,Temp^,lens);
           Move(Pointer(S)^,Temp^,lens);
           fpc_ansistr_decr_ref(Pointer(s));
           fpc_ansistr_decr_ref(Pointer(s));
           Pointer(S):=Temp;
           Pointer(S):=Temp;