Browse Source

* Recommitted the arraydef overflow bugfix.

daniel 26 years ago
parent
commit
df07c1a0f5
2 changed files with 26 additions and 10 deletions
  1. 18 7
      compiler/symdef.inc
  2. 8 3
      compiler/types.pas

+ 18 - 7
compiler/symdef.inc

@@ -1790,11 +1790,16 @@
 
     function tarraydef.size : longint;
       begin
-         { dirty hack to overcome an overflow (PFV) }
-         if highrange=$7fffffff then
-          size:=$7fffffff
-         else
-          size:=(highrange-lowrange+1)*elesize;
+        {Tarraydef.size may never be called for an open array!}
+        if highrange<lowrange then
+            internalerror($99080501);
+        If (highrange-lowrange = $7fffffff) or
+           (($7fffffff div elesize + elesize -1) < (highrange - lowrange)) Then
+          Begin
+            Message(sym_e_segment_too_large);
+            size := 4
+          End
+        Else size:=(highrange-lowrange+1)*elesize;
       end;
 
 
@@ -3585,8 +3590,14 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.144  1999-08-06 23:36:42  peter
-    * removed daniels changes, because it broke all 'array of ...' code
+  Revision 1.145  1999-08-07 13:36:54  daniel
+  * Recommitted the arraydef overflow bugfix.
+
+  Revision 1.143  1999/08/06 11:13:30  peter
+    * fixed message which was wrong styled
+
+  Revision 1.142  1999/08/05 22:41:34  daniel
+  *** empty log message ***
 
   Revision 1.141  1999/08/05 16:53:13  peter
     * V_Fatal=1, all other V_ are also increased

+ 8 - 3
compiler/types.pas

@@ -528,7 +528,8 @@ implementation
            (def^.deftype = formaldef) or
            { copy directly small records or arrays unless array of const ! PM }
            ((def^.deftype in [arraydef,recorddef]) and
-            ((def^.size>4) or
+            ((Parraydef(def)^.highrange<Parraydef(def)^.lowrange) 
+             or (def^.size>4) or
              ((def^.deftype=arraydef) and
               (parraydef(def)^.IsConstructor or
                parraydef(def)^.isArrayOfConst or
@@ -974,8 +975,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.81  1999-08-06 23:36:44  peter
-    * removed daniels changes, because it broke all 'array of ...' code
+  Revision 1.82  1999-08-07 13:36:56  daniel
+  * Recommitted the arraydef overflow bugfix.
+
+  Revision 1.80  1999/08/05 22:42:49  daniel
+  * Fixed potential bug for open arrays (Their size is not known at
+    compilation time).
 
   Revision 1.79  1999/08/03 22:03:41  peter
     * moved bitmask constants to sets