Browse Source

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

Pierre Muller 6 months ago
parent
commit
c6c05f8395
1 changed files with 5 additions and 1 deletions
  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;