Forráskód Böngészése

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 éve
szülő
commit
9ca8f0afaa
1 módosított fájl, 2 hozzáadás és 1 törlés
  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)