From 5da801d12b746878ee94072b2817ff1bb3298023 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 24270726..c9bdc8cd 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; }