1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

Kernel/TmpFS: Stop leaking directory entry metadata

When creating and removing a child to a TmpFS directory, we were
forgetting to delete the TmpFSInode::Child struct.
This commit is contained in:
Andreas Kling 2021-09-07 20:10:06 +02:00
parent e550d53c0f
commit 049d846eb9

View file

@ -277,6 +277,7 @@ KResult TmpFSInode::add_child(Inode& child, StringView const& name, mode_t)
return ENAMETOOLONG;
auto name_kstring = TRY(KString::try_create(name));
// Balanced by `delete` in remove_child()
auto* child_entry = new (nothrow) Child { move(name_kstring), static_cast<TmpFSInode&>(child) };
if (!child_entry)
return ENOMEM;
@ -303,6 +304,8 @@ KResult TmpFSInode::remove_child(StringView const& name)
child->inode->did_delete_self();
m_children.remove(*child);
did_remove_child(child_id, name);
// Balanced by `new` in add_child()
delete child;
return KSuccess;
}