From 7bb1c642ddcb57aa65e5b3e94139082637f688a4 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 3 Oct 2011 16:53:42 +0000 Subject: [PATCH] * fix division by zero in alignment code, should resolve #20265 an #20240 git-svn-id: trunk@19338 - --- compiler/ncgld.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ncgld.pas b/compiler/ncgld.pas index 8b8fa8bf12..28716c5287 100644 --- a/compiler/ncgld.pas +++ b/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