diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-03-27 09:34:29 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2010-03-27 09:34:29 +0100 |
| commit | dc320a2c0affe81fc54d13cc454b5987a62c7894 (patch) | |
| tree | 0e4ba689e817141523d66fcaf60284186dd71b39 | |
| parent | 112c3f0690d02c6a784fdfa9710c679487452fe9 (diff) | |
| download | tuxcmd-dc320a2c0affe81fc54d13cc454b5987a62c7894.tar.xz | |
Properly handle failed stat
Found when trying to get info of a non-existent file (badly constructed path).
| -rw-r--r-- | UCore.pas | 7 | ||||
| -rw-r--r-- | vfs/UVFSCore.pas | 11 |
2 files changed, 12 insertions, 6 deletions
@@ -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; diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index 0ce7e1f..b39ad8e 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -523,12 +523,13 @@ begin end; try P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), FollowSymlinks, AddFullPath, Error); - if P <> nil then + if P <> nil then begin Result := GetDataItemFromVFSItem(P); - if P^.FName <> nil then real_libc_free(P^.FName); - if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); - if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); - real_libc_free(P); + if P^.FName <> nil then real_libc_free(P^.FName); + if P^.FDisplayName <> nil then real_libc_free(P^.FDisplayName); + if P^.sLinkTo <> nil then real_libc_free(P^.sLinkTo); + real_libc_free(P); + end; except on E: Exception do begin DebugMsg(['^^VFS (EE): GetFileInfo: Exception: ', E.Message]); |
