Преглед на файлове

* don't take the address of element 0 of a dynamic array in
tcallparanode.copy_value_by_ref_para() if the array is empty
(mantis #30007)

git-svn-id: trunk@33595 -

Jonas Maebe преди 9 години
родител
ревизия
130d9fee91
променени са 3 файла, в които са добавени 32 реда и са изтрити 7 реда
  1. 1 0
      .gitattributes
  2. 15 7
      compiler/ncal.pas
  3. 16 0
      tests/webtbs/tw30007.pp

+ 1 - 0
.gitattributes

@@ -15038,6 +15038,7 @@ tests/webtbs/tw29958.pp svneol=native#text/pascal
 tests/webtbs/tw2998.pp svneol=native#text/plain
 tests/webtbs/tw2999.pp svneol=native#text/plain
 tests/webtbs/tw29992.pp svneol=native#text/plain
+tests/webtbs/tw30007.pp svneol=native#text/plain
 tests/webtbs/tw30030.pp svneol=native#text/pascal
 tests/webtbs/tw30035.pp svneol=native#text/plain
 tests/webtbs/tw30035a.pp svneol=native#text/plain

+ 15 - 7
compiler/ncal.pas

@@ -303,7 +303,7 @@ implementation
       verbose,globals,
       symconst,defutil,defcmp,
       htypechk,pass_1,
-      ncnv,nld,ninl,nadd,ncon,nmem,nset,nobjc,
+      ncnv,nflw,nld,ninl,nadd,ncon,nmem,nset,nobjc,
       ngenutil,objcutil,
       procinfo,cpuinfo,
       wpobase;
@@ -765,16 +765,24 @@ implementation
                  { move(para,temp,sizeof(arr)) (no "left.getcopy" below because
                    we replace left afterwards) }
                  addstatement(initstat,
-                   ccallnode.createintern('MOVE',
-                     ccallparanode.create(
-                       arraysize,
+                   cifnode.create_internal(
+                     caddnode.create_internal(
+                       unequaln,
+                       arraysize.getcopy,
+                       genintconstnode(0)
+                     ),
+                     ccallnode.createintern('MOVE',
                        ccallparanode.create(
-                         cderefnode.create(ctemprefnode.create(paratemp)),
+                         arraysize,
                          ccallparanode.create(
-                           arraybegin,nil
+                           cderefnode.create(ctemprefnode.create(paratemp)),
+                           ccallparanode.create(
+                             arraybegin,nil
+                           )
                          )
                        )
-                     )
+                     ),
+                     nil
                    )
                  );
                  { no reference count increases, that's still done on the callee

+ 16 - 0
tests/webtbs/tw30007.pp

@@ -0,0 +1,16 @@
+program project6;
+
+{$r+}
+
+function LinesToText(Lines: array of String): String;
+begin
+end;
+
+var
+  SomeLines: array of String;
+begin
+  SetLength(SomeLines,1);
+  LinesToText(SomeLines); // <-- ok
+  SetLength(SomeLines,0);
+  LinesToText(SomeLines); // <-- range error
+end.