Project JEDI - Issue Tracker - JEDI VCL
Viewing Issue Advanced Details
6595 00 JVCL Components block random 2017-09-08 13:28 2018-10-28 17:26
vaniusrb  
 
normal  
feedback Daily / GIT  
open  
none    
none  
0006595: TJvTFDays testing wrong integer object typecast test
Function TJvTFApptMap.HasAppt was testing if FData has object with ">0"
instead "<> 0". Object with integer typecast can returns negative values
(it happened with Delphi 10.2 Tokyo build, causing infinity loop)

This line
      if Test > 0 then

must be
      if Test <> 0 then
Issue History
2017-09-08 13:28 vaniusrb New Issue
2018-07-18 16:00 obones Note Added: 0021538
2018-07-18 16:00 obones Status new => feedback
2018-10-28 17:26 mh Note Added: 0021585

Notes
(0021538)
obones   
2018-07-18 16:00   
Could you check if the issue is still present in the latest GIT content? If yes, please provide the zipped sources of an application showing this.
(0021585)
mh   
2018-10-28 17:26   
That code line is still there and Test is a NativeInt var so it could get negative:

function TJvTFApptMap.HasAppt(Appt: TJvTFAppt): Boolean;
var
  MapRow, MapCol, StartRow, EndRow, ApptsExamined: Integer;
  Test: NativeInt;
  ApptGrid: TJvTFDays;
begin
  FGridCol.CalcStartEndRows(Appt, StartRow, EndRow);

  StartRow := Greater(StartRow, 0);

  ApptGrid := FGridCol.ColCollection.ApptGrid;
  if Assigned(ApptGrid) then
    EndRow := Lesser(EndRow, ApptGrid.RowCount - 1)
  else
    EndRow := Lesser(EndRow, FGridCol.ColCollection.Printer.RowCount - 1);

  MapRow := 0;
  Result := False;
  while (MapRow <= EndRow) and not Result do
  begin
    MapCol := 1;
    ApptsExamined := 0;
    while (ApptsExamined < FData[MapRow, -1]) and not Result do
    begin
      Test := FData[MapRow, MapCol];
      if Test > 0 then
      begin
        Inc(ApptsExamined);
        if Test = NativeInt(Appt) then
          Result := True;
      end;

      Inc(MapCol);
    end;

    Inc(MapRow);
  end;
end;

The FData var is a sparse mag which contains NativeInt values so they could get negative. I don't know this component, but I guess the author of this report is right about changing the comparison as otherwise the while loop could really become an endless loop!