summaryrefslogtreecommitdiff
path: root/UCore.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2010-03-27 09:34:29 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2010-03-27 09:34:29 +0100
commitdc320a2c0affe81fc54d13cc454b5987a62c7894 (patch)
tree0e4ba689e817141523d66fcaf60284186dd71b39 /UCore.pas
parent112c3f0690d02c6a784fdfa9710c679487452fe9 (diff)
downloadtuxcmd-dc320a2c0affe81fc54d13cc454b5987a62c7894.tar.xz
Properly handle failed stat
Found when trying to get info of a non-existent file (badly constructed path).
Diffstat (limited to 'UCore.pas')
-rw-r--r--UCore.pas7
1 files changed, 6 insertions, 1 deletions
diff --git a/UCore.pas b/UCore.pas
index cc6929f..bf5c012 100644
--- a/UCore.pas
+++ b/UCore.pas
@@ -520,11 +520,16 @@ end;
function GetFileInfoSL(Engine: TPanelEngine; const APath: string): PDataItemSL;
var ItemSL: PDataItemSL;
+ DataItem: PDataItem;
begin
+ Result := nil;
+ DataItem := Engine.GetFileInfo(APath, False, True, nil);
+ if DataItem = nil then Exit; // Inaccessible file
+
ItemSL := malloc(sizeof(TDataItemSL));
memset(ItemSL, 0, sizeof(TDataItemSL));
// * TODO: report errors? same way as for FillDirFiles
- ItemSL^.DataItem := Engine.GetFileInfo(APath, False, True, nil);
+ ItemSL^.DataItem := DataItem;
ItemSL^.Stage1 := True;
ItemSL^.Level := 1;
Result := ItemSL;