diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-04 17:29:18 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-10-04 17:29:18 +0200 |
| commit | 47208d263f3940ec65e7f94b9cc8f4c588234ac5 (patch) | |
| tree | f7b3bb5a5bfa655d0568a44e6fbdf17f08ce106c /UChecksumDruid.pas | |
| parent | 9edcc05f98afb705071e9a906492aaf4d3a10160 (diff) | |
| download | tuxcmd-47208d263f3940ec65e7f94b9cc8f4c588234ac5.tar.xz | |
Always check GetFileInfoSL() result
This prevents crashes when file was deleted and included in selection for some operation.
Also fix minor memory leaks...
Diffstat (limited to 'UChecksumDruid.pas')
| -rw-r--r-- | UChecksumDruid.pas | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/UChecksumDruid.pas b/UChecksumDruid.pas index 34a2570..346dc3f 100644 --- a/UChecksumDruid.pas +++ b/UChecksumDruid.pas @@ -444,7 +444,10 @@ begin MaxSize := 0; for i := 0 to FileNames.Count - 1 do begin Stat := Engine.GetFileInfoSL(FileNames[i]); - if Assigned(Stat) then Inc(MaxSize, Stat.Size); + if Assigned(Stat) then begin + Inc(MaxSize, Stat.Size); + FreeDataItem(Stat); + end; end; Progress.Max := MaxSize; Progress.Value := 0; @@ -466,7 +469,10 @@ begin (i = FileNames.Count - 1) or SeparateFileCheckBox.Checked); end; except end; - if Assigned(Stat) then Progress.Value := LastValue + Stat.Size; + if Assigned(Stat) then begin + Progress.Value := LastValue + Stat.Size; + FreeDataItem(Stat); + end; Progress.Text := Format('%d %%', [Trunc(Progress.Fraction * 100)]); Application.ProcessMessages; CheckStop; @@ -608,8 +614,11 @@ begin SysUtils.FormatDateTime('mm.dd.yyyy "at" hh:nn:ss', Now)]); for i := 0 to FileNames.Count - 1 do begin Stat := Engine.GetFileInfoSL(FileNames[i]); - if Assigned(Stat) then s := s + Format('; %s %s %s'#13#10, [PadRightStr(IntToStr(Stat^.Size), 11), - FormatDate(Stat^.ModifyTime, True, True, 999, 999, 1, '%Y-%m-%d', '%k:%M.%S'), ExtractFileName(FileNames[i])]); + if Assigned(Stat) then begin + s := s + Format('; %s %s %s'#13#10, [PadRightStr(IntToStr(Stat^.Size), 11), + FormatDate(Stat^.ModifyTime, True, True, 999, 999, 1, '%Y-%m-%d', '%k:%M.%S'), ExtractFileName(FileNames[i])]); + FreeDataItem(Stat); + end; end; s := s + '; \----'#13#10'; '#13#10; |
