Pārlūkot izejas kodu

Fix previous commit 48688 to avoid accessing 'invalid' positions in sym.value.valueptr

git-svn-id: trunk@48689 -
(cherry picked from commit 34fd36f817dcbd2bd6d3d2d3100a29d62c5f573e)
pierre 4 gadi atpakaļ
vecāks
revīzija
39ba1c39be
1 mainītis faili ar 6 papildinājumiem un 5 dzēšanām
  1. 6 5
      compiler/dbgstabs.pas

+ 6 - 5
compiler/dbgstabs.pas

@@ -1587,6 +1587,7 @@ implementation
       var
         st : string;
         ss : ansistring;
+        i : longint;
       begin
         ss:='';
         { Don't write info for default parameter values, the N_Func breaks
@@ -1600,12 +1601,12 @@ implementation
             begin
               if sym.value.len<200 then
                 begin
-                  s:=strpas(pchar(sym.value.valueptr));
-                  s:=copy(s,1,sym.value.len);
-                  if target_dbg.id=dbg_stabs then
-                    st:='s'''+backspace_quote(octal_quote(s,[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
+                  setlength(ss,sym.value.len);
+                  for i:=0 to sym.value.len-1 do
+                    ss[i_1]:=pchar(sym.value.valueptr)[i];
+                    st:='s'''+backspace_quote(octal_quote(ss,[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
                   else
-                    st:='s'''+stabx_quote_const(octal_quote(s,[#0..#9,#11,#12,#14..#31,'''']))+'''';
+                    st:='s'''+stabx_quote_const(octal_quote(ss,[#0..#9,#11,#12,#14..#31,'''']))+'''';
                 end
               else
                 st:='<constant string too long>';