View Issue Details

IDProjectCategoryView StatusLast Update
0006299JEDI VCL00 JVCL Componentspublic2014-08-31 22:41
ReporterZENsanAssigned To 
PrioritynormalSeveritytweakReproducibilityalways
Status acknowledgedResolutionopen 
PlatformWindowsOSWindows 7OS Version
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0006299: Unsafe pattern in function
Descriptionfunction TJvCheckListBox.GetChecked: TStringList;
function TJvCheckListBox.GetUnChecked: TStringList;

These function uses a bit unsafe handling of the result.

Actual:
var
  I: Integer;
begin
  Result := TStringList.Create;
  for I := 0 to Items.Count - 1 do
    if Checked[I] then
      Result.AddObject(Items[I], Items.Objects[I]);
end;

Expected:
var
  I: Integer;
begin
  Result := TStringList.Create;
  try
    for I := 0 to Items.Count - 1 do
      if Checked[I] then
        Result.AddObject(Items[I], Items.Objects[I]);
  except
    Result.Free;
    raise;
  end;
end;

Quite minor, but in case of out of memory these produces the memory leak.
Possibly there are some similar places.
Additional InformationQuite rare case, but still theoretically and practically possible.
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2014-06-20 13:15 ZENsan New Issue
2014-08-31 22:41 obones Status new => acknowledged