Browse Source

* fix division by zero in alignment code, should resolve #20265 an #20240

git-svn-id: trunk@19338 -
florian 14 years ago
parent
commit
7bb1c642dd
1 changed files with 2 additions and 1 deletions
  1. 2 1
      compiler/ncgld.pas

+ 2 - 1
compiler/ncgld.pas

@@ -780,7 +780,8 @@ implementation
                             len:=left.resultdef.size;
                             len:=left.resultdef.size;
 
 
                             { data smaller than an aint has less alignment requirements }
                             { data smaller than an aint has less alignment requirements }
-                            alignmentrequirement:=min(len,sizeof(aint));
+                            { max(1,...) avoids div by zero in case of an empty record  }
+                            alignmentrequirement:=min(max(1,len),sizeof(aint));
 
 
                             if (right.location.reference.offset mod alignmentrequirement<>0) or
                             if (right.location.reference.offset mod alignmentrequirement<>0) or
                               (left.location.reference.offset mod alignmentrequirement<>0) or
                               (left.location.reference.offset mod alignmentrequirement<>0) or