瀏覽代碼

--- Merging r19338 into '.':
U compiler/ncgld.pas

# revisions: 19338
r19338 | florian | 2011-10-03 18:53:42 +0200 (Mon, 03 Oct 2011) | 1 line
Changed paths:
M /trunk/compiler/ncgld.pas

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

git-svn-id: branches/fixes_2_6@25257 -

marco 12 年之前
父節點
當前提交
cced7da505
共有 1 個文件被更改,包括 2 次插入1 次删除
  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