summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-02-20 17:33:14 +0300
committerAndreas Kling <kling@serenityos.org>2020-02-20 19:13:20 +0100
commit1d2986ea15eab8ea8b8855147a16de7662729f31 (patch)
treea84974a49fec9eccccddbec1e4a156594d0835a0 /Kernel/FileSystem/VirtualFileSystem.cpp
parent3439498744028f6f38a172f119949d69d70cde19 (diff)
downloadserenity-1d2986ea15eab8ea8b8855147a16de7662729f31.zip
Kernel: Fix a panic in VFS::rename()
If we get an -ENOENT when resolving the target because of some part, that is not the very last part, missing, we should just return the error instead of panicking later :^) To test: $ mkdir /tmp/foo/ $ mv /tmp/foo/ /tmp/bar/ Related to https://github.com/SerenityOS/serenity/issues/1253
Diffstat (limited to 'Kernel/FileSystem/VirtualFileSystem.cpp')
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index 8405be4ce3..f247757e67 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -433,7 +433,7 @@ KResult VFS::rename(StringView old_path, StringView new_path, Custody& base)
RefPtr<Custody> new_parent_custody;
auto new_custody_or_error = resolve_path(new_path, base, &new_parent_custody);
if (new_custody_or_error.is_error()) {
- if (new_custody_or_error.error() != -ENOENT)
+ if (new_custody_or_error.error() != -ENOENT || !new_parent_custody)
return new_custody_or_error.error();
}