mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-16 21:04:20 +00:00
Kernel: Replace make<T>() with adopt_own_if_nonnull() in Ext2FileSystem
The make<T> factory function allocates internally and immediately dereferences the pointer, and always returns a NonnullOwnPtr<T> making it impossible to propagate an error on OOM.
This commit is contained in:
parent
5dc5f31f76
commit
fb40da0429
|
@ -1495,7 +1495,10 @@ KResultOr<Ext2FS::CachedBitmap*> Ext2FS::get_bitmap_block(BlockIndex bitmap_bloc
|
|||
dbgln("Ext2FS: Failed to load bitmap block {}", bitmap_block_index);
|
||||
return result;
|
||||
}
|
||||
if (!m_cached_bitmaps.try_append(make<CachedBitmap>(bitmap_block_index, move(block))))
|
||||
auto new_bitmap = adopt_own_if_nonnull(new CachedBitmap(bitmap_block_index, move(block)));
|
||||
if (!new_bitmap)
|
||||
return ENOMEM;
|
||||
if (!m_cached_bitmaps.try_append(move(new_bitmap)))
|
||||
return ENOMEM;
|
||||
return m_cached_bitmaps.last();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue