Forráskód Böngészése

* Properly zero-terminate ansistring when calling unicode2ascii

Michaël Van Canneyt 1 éve
szülő
commit
6652fa7919
1 módosított fájl, 4 hozzáadás és 1 törlés
  1. 4 1
      compiler/pexpr.pas

+ 4 - 1
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);