From d7db2108823e1433edff5e94fb856d172e7c9cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 26 Jan 2004 02:08:31 +0000 Subject: [PATCH] Fixed a bug that could happen when calling Inode::Create() with unusual arguments (such for creating a root directory, for example). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6312 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 1f0f464730..d325723baf 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -2007,8 +2007,9 @@ Inode::Create(Transaction *transaction, Inode *parent, const char *name, int32 m // (live queries might want to access us after this) Index index(volume); - if (inode->IsRegularNode()) { + if (inode->IsRegularNode() && name != NULL) { // the name index only contains regular files + // (but not the root node where name == NULL) status = index.InsertName(transaction, name, inode); if (status < B_OK && status != B_BAD_INDEX) { // We have to remove the node from the parent at this point, @@ -2016,7 +2017,7 @@ Inode::Create(Transaction *transaction, Inode *parent, const char *name, int32 m // case (and if it fails, we can't do anything about it...) if (tree) tree->Remove(transaction, name, inode->ID()); - else + else if (parent != NULL && (mode & S_ATTR_DIR) != 0) parent->Node()->attributes.SetTo(0, 0, 0); return status;