Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006299 [JEDI VCL] 00 JVCL Components tweak always 2014-06-20 13:15 2014-08-31 22:41
Reporter ZENsan View Status public  
Assigned To
Priority normal Resolution open  
Status acknowledged   Product Version Daily / GIT
Summary 0006299: Unsafe pattern in function
Description function 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 Information Quite rare case, but still theoretically and practically possible.
Tags No tags attached.
Attached Files

- Relationships

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker