From 9ca8f0afaa632d08b987d7c171041d5248f0678e Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 12 May 2021 23:34:00 -0700 Subject: [PATCH] Kernel: Replace make() with adopt_own_if_nonnull() in KBufferBuilder The make factory function allocates internally and immediately dereferences the pointer, and always returns a NonnullOwnPtr making it impossible to propagate an error on OOM. --- Kernel/KBufferBuilder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp index 0ccc1f870d..d1665b09ef 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -38,7 +38,8 @@ OwnPtr KBufferBuilder::build() { if (!flush()) return {}; - return make(move(m_buffer)); + + return adopt_own_if_nonnull(new KBuffer(move(m_buffer))); } KBufferBuilder::KBufferBuilder(bool can_expand)