View Issue Details

IDProjectCategoryView StatusLast Update
0006595JEDI VCL00 JVCL Componentspublic2019-03-11 17:02
ReportervaniusrbAssigned Toobones 
PrioritynormalSeverityblockReproducibilityrandom
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in VersionDaily / GIT 
Summary0006595: TJvTFDays testing wrong integer object typecast test
DescriptionFunction 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
TagsNo tags attached.

Activities

obones

2018-07-18 16:00

administrator   ~0021538

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.

mh

2018-10-28 17:26

reporter   ~0021585

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!

mh

2019-03-07 21:16

reporter   ~0021617

I made your small change from
if Test > 0 then to
if Test <> 0 then
in a branch and created this pull request for it:

https://github.com/project-jedi/jvcl/pull/60

Hopefully it will get included soon.

mh

2019-03-10 10:42

reporter   ~0021629

Replaced the pull request with this one, as my old one contained unrelated modifications as well (Git is still new for me):
https://github.com/project-jedi/jvcl/pull/66

obones

2019-03-11 17:02

administrator   ~0021631

Thanks, this is now merged in GIT

Issue History

Date Modified Username Field Change
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
2019-03-07 21:16 mh Note Added: 0021617
2019-03-10 10:42 mh Note Added: 0021629
2019-03-11 17:02 obones Note Added: 0021631
2019-03-11 17:02 obones Status feedback => resolved
2019-03-11 17:02 obones Fixed in Version => Daily / GIT
2019-03-11 17:02 obones Resolution open => fixed
2019-03-11 17:02 obones Assigned To => obones