From d4bdb96163a95b46c745d3c99b80123a0cb64d0b Mon Sep 17 00:00:00 2001 From: Sergey Larin Date: Sun, 30 Jan 2022 13:25:49 +0300 Subject: [PATCH] In tai_string.getcopy added zero-terminator only when needed --- compiler/aasmtai.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index a6e5db1b97..df3d0e36f5 100644 --- a/compiler/aasmtai.pas +++ b/compiler/aasmtai.pas @@ -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;