From 47208d263f3940ec65e7f94b9cc8f4c588234ac5 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 4 Oct 2009 17:29:18 +0200 Subject: Always check GetFileInfoSL() result This prevents crashes when file was deleted and included in selection for some operation. Also fix minor memory leaks... --- UMain.pas | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'UMain.pas') diff --git a/UMain.pas b/UMain.pas index 5729c16..b762839 100644 --- a/UMain.pas +++ b/UMain.pas @@ -3607,8 +3607,11 @@ begin Stat := Engine.GetFileInfoSL(Filename); if Assigned(Stat) and (Stat^.Size > ConfEditViewFileSizeLimit) and (Application.MessageBox(LANGTheFileYouAreTryingToOpenIsQuiteBig, [mbYes, mbNo], mbWarning, mbNone, mbNo) = mbNo) - then Exit; - + then begin + FreeDataItem(Stat); + Exit; + end; + FreeDataItem(Stat); if View then s := ConfViewer else s := ConfEditor; @@ -3713,6 +3716,7 @@ begin b := ExecuteProgram(QuoteStr(Path), ExtractFilePath(Path), AutodetectGUI, RunInTerminal, i); libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS + FreeDataItem(Stat); end else begin if Engine is TVFSEngine then begin HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False); @@ -4115,6 +4119,7 @@ begin DoRefresh(not LeftPanel, True, True); end; finally + FreeDataItem(Stat); FChmod.Free; end; finally @@ -4207,6 +4212,7 @@ begin DoRefresh(not LeftPanel, True, True); end; finally + FreeDataItem(Stat); FChown.Free; end; finally @@ -4460,6 +4466,8 @@ begin Item.Visible := False; // Item.Enabled := not UpDir; FilePopupMenu.Add(Item); + + FreeDataItem(DataItem); end; procedure TFMain.FilePopupMenuItemClick(Sender: TObject); @@ -4524,6 +4532,7 @@ begin if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [FileName]), [mbOK], mbError, mbNone, mbOK); end; end; + FreeDataItem(DataItem); finally Application.ProcessMessages; InternalUnLock; @@ -6391,6 +6400,7 @@ begin DoRefresh(not LeftPanel, True, True); end; finally + FreeDataItem(Stat); FProperties.Free; end; finally @@ -6501,6 +6511,7 @@ begin if Command = '' then Command := LANGHandleRunFromArchive_SelfExecutable; FRunFromVFS.OpensWithLabel2.Caption := Format('%s ', [Command]); end; + FreeDataItem(Stat); end else begin FRunFromVFS.SizeLabel2.Caption := Format('%s ', ['??']); FRunFromVFS.PackedSizeLabel2.Caption := Format('%s ', ['??']); @@ -6514,8 +6525,6 @@ begin FRunFromVFS.DateLabel2.UseMarkup := True; FRunFromVFS.OpensWithLabel2.UseMarkup := True; - FreeDataItem(Stat); - Res := FRunFromVFS.Run; FRunFromVFS.Close; FRunFromVFS.Free; -- cgit v1.2.3