Fix crash when trying to open a non-existing file.

This commit is contained in:
Adrien Destugues
2014-01-16 09:30:13 +01:00
parent 385a7d89b7
commit 3db3864644
+4 -1
View File
@@ -43,6 +43,7 @@ status_t
BFileRequest::_ProtocolLoop() BFileRequest::_ProtocolLoop()
{ {
BNode node(fUrl.Path().String()); BNode node(fUrl.Path().String());
if (node.IsSymLink()) { if (node.IsSymLink()) {
// Traverse the symlink and start over // Traverse the symlink and start over
BEntry entry(fUrl.Path().String(), true); BEntry entry(fUrl.Path().String(), true);
@@ -84,12 +85,14 @@ BFileRequest::_ProtocolLoop()
return B_OK; return B_OK;
} }
assert(node.IsDirectory());
node_ref ref; node_ref ref;
status_t error = node.GetNodeRef(&ref); status_t error = node.GetNodeRef(&ref);
// Stop here, and don't hit the assert below, if the file doesn't exist.
if (error != B_OK) if (error != B_OK)
return error; return error;
assert(node.IsDirectory());
BDirectory directory(&ref); BDirectory directory(&ref);
fResult.SetContentType("application/x-ftp-directory; charset=utf-8"); fResult.SetContentType("application/x-ftp-directory; charset=utf-8");