瀏覽代碼

Check that index value is not below lower bound in TMessage.Valid method

Pierre Muller 8 月之前
父節點
當前提交
c6c05f8395
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      compiler/cmsgs.pas

+ 5 - 1
compiler/cmsgs.pas

@@ -461,8 +461,12 @@ begin
 end;
 end;
 
 
 function TMessage.Valid(nr:longint):boolean;
 function TMessage.Valid(nr:longint):boolean;
+var
+  i,j : longint;
 begin
 begin
-  result:=(nr div 1000<msgparts) and (nr mod 1000<msgidxmax[nr div 1000]) and assigned(msgidx[nr div 1000]^[nr mod 1000]);
+  i:=nr div 1000;
+  j:=nr mod 1000;
+  result:=(i>=low(msgstates)) and (i<msgparts) and (j<msgidxmax[i]) and assigned(msgidx[i]^[j]);
 end;
 end;
 
 
 procedure TMessage.ResetStates;
 procedure TMessage.ResetStates;