diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-09-06 03:29:52 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 01:53:26 +0200 |
commit | 97e97bccab085823d1365cb54142fd8c41dbcd8c (patch) | |
tree | 9008687dbcdfb6f36f6dc6372aa382b15b9d36c8 /Userland/Libraries/LibIPC/Decoder.cpp | |
parent | 3a9f00c59bad7735970c72cb940d08161fda09b0 (diff) | |
download | serenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip |
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Userland/Libraries/LibIPC/Decoder.cpp')
-rw-r--r-- | Userland/Libraries/LibIPC/Decoder.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibIPC/Decoder.cpp b/Userland/Libraries/LibIPC/Decoder.cpp index ed63dc6472..677bf69e02 100644 --- a/Userland/Libraries/LibIPC/Decoder.cpp +++ b/Userland/Libraries/LibIPC/Decoder.cpp @@ -110,10 +110,14 @@ bool Decoder::decode(ByteBuffer& value) return true; } if (length == 0) { - value = ByteBuffer::create_uninitialized(0); + value = {}; return true; } - value = ByteBuffer::create_uninitialized(length); + if (auto buffer_result = ByteBuffer::create_uninitialized(length); buffer_result.has_value()) + value = buffer_result.release_value(); + else + return false; + m_stream >> value.bytes(); return !m_stream.handle_any_error(); } |