From dc320a2c0affe81fc54d13cc454b5987a62c7894 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 27 Mar 2010 09:34:29 +0100 Subject: Properly handle failed stat Found when trying to get info of a non-existent file (badly constructed path). --- UCore.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'UCore.pas') 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; -- cgit v1.2.3