From c45ada6ccbb7c78e463b9e0b8774b48ab579c788 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 1 Apr 2023 00:22:03 +0300 Subject: [PATCH] Kernel: fix ext2 failed creation memory leak --- kernel/kernel/FS/Ext2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/kernel/FS/Ext2.cpp b/kernel/kernel/FS/Ext2.cpp index 2427072660..c9bdc8cdb7 100644 --- a/kernel/kernel/FS/Ext2.cpp +++ b/kernel/kernel/FS/Ext2.cpp @@ -438,8 +438,10 @@ namespace Kernel Ext2FS* ext2fs = new Ext2FS(partition); if (ext2fs == nullptr) return BAN::Error::from_errno(ENOMEM); + BAN::ScopeGuard guard([ext2fs] { delete ext2fs; }); TRY(ext2fs->initialize_superblock()); TRY(ext2fs->initialize_root_inode()); + guard.disable(); return ext2fs; }