summaryrefslogtreecommitdiff
path: root/UCore.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-04 17:29:18 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2009-10-04 17:29:18 +0200
commit47208d263f3940ec65e7f94b9cc8f4c588234ac5 (patch)
treef7b3bb5a5bfa655d0568a44e6fbdf17f08ce106c /UCore.pas
parent9edcc05f98afb705071e9a906492aaf4d3a10160 (diff)
downloadtuxcmd-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 'UCore.pas')
-rw-r--r--UCore.pas42
1 files changed, 36 insertions, 6 deletions
diff --git a/UCore.pas b/UCore.pas
index 50f705f..5481bf9 100644
--- a/UCore.pas
+++ b/UCore.pas
@@ -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;