Browse Source

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.
Brian Gianforcaro 4 years ago
parent
commit
9ca8f0afaa
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Kernel/KBufferBuilder.cpp

+ 2 - 1
Kernel/KBufferBuilder.cpp

@@ -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)