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

Kernel: Replace make<T>() with adopt_own_if_nonnull() in KBufferBuilder

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:
Brian Gianforcaro 2021-05-12 23:34:00 -07:00 committed by Andreas Kling
parent fb40da0429
commit 9ca8f0afaa

View file

@ -38,7 +38,8 @@ OwnPtr<KBuffer> KBufferBuilder::build()
{
if (!flush())
return {};
return make<KBuffer>(move(m_buffer));
return adopt_own_if_nonnull(new KBuffer(move(m_buffer)));
}
KBufferBuilder::KBufferBuilder(bool can_expand)