Jelajahi Sumber

* fixed potential buffer overflow error when creating the fullprocname for
display purposes if there was a parameter with a default value > 255 chars
* replace #0, #10 and #13 in the fullprocname with '.' so they do not cause
line breaks or early string termination when writing them to the
assembler file (mantis #17928)

git-svn-id: trunk@16344 -

Jonas Maebe 14 tahun lalu
induk
melakukan
d36f8ac542
3 mengubah file dengan 23 tambahan dan 2 penghapusan
  1. 1 0
      .gitattributes
  2. 11 2
      compiler/symdef.pas
  3. 11 0
      tests/webtbs/tw17928.pp

+ 1 - 0
.gitattributes

@@ -10748,6 +10748,7 @@ tests/webtbs/tw17907/test.bat svneol=native#text/plain
 tests/webtbs/tw17907/unit1/unit0001.pas svneol=native#text/plain
 tests/webtbs/tw17907/unit2/unit0002.pas svneol=native#text/plain
 tests/webtbs/tw1792.pp svneol=native#text/plain
+tests/webtbs/tw17928.pp svneol=native#text/plain
 tests/webtbs/tw1792a.pp svneol=native#text/plain
 tests/webtbs/tw1798.pp svneol=native#text/plain
 tests/webtbs/tw1820.pp svneol=native#text/plain

+ 11 - 2
compiler/symdef.pas

@@ -2974,8 +2974,17 @@ implementation
                       begin
                       If hpc.value.len>0 then
                         begin
-                        setLength(hs,hpc.value.len);
-                        move(hpc.value.valueptr^,hs[1],hpc.value.len);
+                          setLength(hs,hpc.value.len);
+                          { don't write past the end of hs if the constant
+                            is > 255 chars }
+                          move(hpc.value.valueptr^,hs[1],length(hs));
+                          { make sure that constant strings with newline chars
+                            don't create a linebreak in the assembler code,
+                            since comments are line-based. Also remove nulls
+                            because the comments are written as a pchar. }
+                          ReplaceCase(hs,#0,'.');
+                          ReplaceCase(hs,#10,'.');
+                          ReplaceCase(hs,#13,'.');
                         end;
                       end;
                     constreal :

+ 11 - 0
tests/webtbs/tw17928.pp

@@ -0,0 +1,11 @@
+{ %norun }
+{ %opt=-a }
+
+{$mode delphi}
+
+procedure AddItemsFromString(const aItems: String; const aSeparator: String = #13#10);
+begin
+end;
+
+begin
+end.