From 6652fa79199d9f0d0c1d433b1c7481571bae9f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Wed, 15 Nov 2023 18:58:20 +0100 Subject: [PATCH] * Properly zero-terminate ansistring when calling unicode2ascii --- compiler/pexpr.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index eae017c320..28860eb534 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -5012,6 +5012,7 @@ implementation s : string; pw : pcompilerwidestring; pc : pansichar; + len : Integer; begin get_stringconst:=''; @@ -5026,7 +5027,9 @@ implementation else if (tstringconstnode(p).cst_type in [cst_unicodestring,cst_widestring]) then begin pw:=pcompilerwideString(tstringconstnode(p).value_str); - pc:=getmem(getlengthwidestring(pw)); + len:=getlengthwidestring(pw); + pc:=getmem(Len+1); + pc[len]:=#0; unicode2ascii(pw,pc,current_settings.sourcecodepage); get_stringconst:=strpas(pc); freemem(pc);