mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:37:34 +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
1 changed files with 4 additions and 1 deletions
|
@ -1495,7 +1495,10 @@ KResultOr<Ext2FS::CachedBitmap*> Ext2FS::get_bitmap_block(BlockIndex bitmap_bloc
|
||||||
dbgln("Ext2FS: Failed to load bitmap block {}", bitmap_block_index);
|
dbgln("Ext2FS: Failed to load bitmap block {}", bitmap_block_index);
|
||||||
return result;
|
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 ENOMEM;
|
||||||
return m_cached_bitmaps.last();
|
return m_cached_bitmaps.last();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue