In tai_string.getcopy added zero-terminator only when needed

This commit is contained in:
Sergey Larin 2022-01-30 13:25:49 +03:00
parent a9309072db
commit d4bdb96163

View File

@ -2415,9 +2415,14 @@ implementation
p : tlinkedlistitem;
begin
p:=inherited getcopy;
getmem(tai_string(p).str,len+1);
if (len>0) and (str[len-1]=#0) then
getmem(tai_string(p).str,len)
else
begin
getmem(tai_string(p).str,len+1);
tai_string(p).str[len]:=#0;
end;
move(str^,tai_string(p).str^,len);
tai_string(p).str[len]:=#0;
getcopy:=p;
end;