diff options
| -rw-r--r-- | UChecksum.pas | 9 | ||||
| -rw-r--r-- | UChecksumDruid.pas | 17 | ||||
| -rw-r--r-- | UCore.pas | 42 | ||||
| -rw-r--r-- | UMain.pas | 17 |
4 files changed, 68 insertions, 17 deletions
diff --git a/UChecksum.pas b/UChecksum.pas index 6634601..679d7ef 100644 --- a/UChecksum.pas +++ b/UChecksum.pas @@ -206,9 +206,10 @@ var FD: TEngineFileDes; begin Result := False; Stat := Engine.GetFileInfoSL(FileName); - if (Stat.Size > 128*1024) then begin + if (Stat <> nil) and (Stat.Size > 128*1024) then begin i := integer(Application.MessageBox(Format(LANGTheFileSYouAreTryingToOpenIsQuiteBig, [StrToUTF8(ExtractFileName(FileName))]), [mbYes, mbNo], mbWarning, mbNone, mbNo)); if (i = integer(mbNo)) or (i = 251) then Exit; + FreeDataItem(Stat); end; IsMD5 := (Pos('MD5', WideUpperCase(ExtractFileName(FileName))) > 0) or ((Pos('SFV', WideUpperCase(ExtractFileName(FileName))) = 0) and (Pos('SUM', WideUpperCase(ExtractFileName(FileName))) > 0)); if IsMD5 then MD5Present := True @@ -312,8 +313,10 @@ begin Item.FullPath := IncludeTrailingPathDelimiter(Path) + s2; end; Stat := Engine.GetFileInfoSL(Item.FullPath); - if Assigned(Stat) then Item.Size := Stat.Size - else Item.Size := 0; + if Assigned(Stat) then begin + Item.Size := Stat.Size; + FreeDataItem(Stat); + end else Item.Size := 0; List.Add(Item); ListItem := FileList.Items.Add; ListItem.Data := Item; 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; @@ -682,6 +682,7 @@ var i: longint; Fr: Single; Response: integer; DeleteAll, SkipToNext: boolean; + x: PDataItemSL; begin SkipAll := False; @@ -695,12 +696,18 @@ begin if (not UpDir) and Selected then if IsDir and (not IsLnk) then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; if (AList.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then with SelectedItem^ do if IsDir and (not IsLnk) then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; if Engine.ChangeDir(CurrPath) <> 0 then DebugMsg(['*** WARNING: Cannot change to the origin location, strange behaviour might occur.']); Engine.ExplicitChDir('/'); @@ -1089,6 +1096,11 @@ var DefResponse: integer; // Global variables for this function then begin Response := DefResponse; Item := DestEngine.GetFileInfoSL(NewFilePath); + if Item = nil then begin + DebugMsg(['Something went terribly wrong during copy - Item := DestEngine.GetFileInfoSL(NewFilePath) == NULL!']); + Result := False; + Exit; + end; if Response = 0 then begin case ConfSizeFormat of 5: InfoLabelFormat := '%s, %s'; @@ -1989,6 +2001,7 @@ var i: longint; AList: TList; CurrPath: string; Fr: Single; + x: PDataItemSL; begin SkipAll := False; with SenderThread do begin @@ -2001,12 +2014,18 @@ begin if (not UpDir) and Selected then if IsDir and (not IsLnk) and ParamBool1 then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; if (AList.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then with SelectedItem^ do if IsDir and (not IsLnk) and ParamBool1 then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; Engine.ExplicitChDir('/'); SetProgress1Params(AList.Count); UpdateProgress1(0, '0 %'); @@ -2078,6 +2097,7 @@ var i: longint; AList: TList; CurrPath: string; Fr: Single; + x: PDataItemSL; begin SkipAll := False; with SenderThread do begin @@ -2090,12 +2110,18 @@ begin if (not UpDir) and Selected then if IsDir and (not IsLnk) and ParamBool1 then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; if (AList.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then with SelectedItem^ do if IsDir and (not IsLnk) and ParamBool1 then Engine.FillDirFiles(CurrPath + String(FName), AList, 1) - else AList.Add(Engine.GetFileInfoSL(CurrPath + String(FName))); + else begin + x := Engine.GetFileInfoSL(CurrPath + String(FName)); + if x <> nil then AList.Add(x); + end; Engine.ExplicitChDir('/'); SetProgress1Params(AList.Count); UpdateProgress1(0, '0 %'); @@ -2256,6 +2282,10 @@ var Data: PDataItemSL; begin Result := False; Data := Engine.GetFileInfoSL(FileName); + if Data = nil then begin + Result := False; + Exit; + end; try AFSymlink := TFSymlink.Create(Application); AFSymlink.Caption := LANGFEditSymlink_Caption; @@ -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<span weight="ultrabold"> </span>', [Command]); end; + FreeDataItem(Stat); end else begin FRunFromVFS.SizeLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', ['??']); FRunFromVFS.PackedSizeLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', ['??']); @@ -6514,8 +6525,6 @@ begin FRunFromVFS.DateLabel2.UseMarkup := True; FRunFromVFS.OpensWithLabel2.UseMarkup := True; - FreeDataItem(Stat); - Res := FRunFromVFS.Run; FRunFromVFS.Close; FRunFromVFS.Free; |
