Procházet zdrojové kódy

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

git-svn-id: trunk@19338 -
florian před 14 roky
rodič
revize
7bb1c642dd
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      compiler/ncgld.pas

+ 2 - 1
compiler/ncgld.pas

@@ -780,7 +780,8 @@ implementation
                             len:=left.resultdef.size;
 
                             { 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
                               (left.location.reference.offset mod alignmentrequirement<>0) or