summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWasm/Parser
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-09-06 03:29:52 +0430
committerAndreas Kling <kling@serenityos.org>2021-09-06 01:53:26 +0200
commit97e97bccab085823d1365cb54142fd8c41dbcd8c (patch)
tree9008687dbcdfb6f36f6dc6372aa382b15b9d36c8 /Userland/Libraries/LibWasm/Parser
parent3a9f00c59bad7735970c72cb940d08161fda09b0 (diff)
downloadserenity-97e97bccab085823d1365cb54142fd8c41dbcd8c.zip
Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
Diffstat (limited to 'Userland/Libraries/LibWasm/Parser')
-rw-r--r--Userland/Libraries/LibWasm/Parser/Parser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp
index 4581f4fa75..c201265088 100644
--- a/Userland/Libraries/LibWasm/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp
@@ -738,7 +738,10 @@ ParseResult<CustomSection> CustomSection::parse(InputStream& stream)
if (name.is_error())
return name.error();
- auto data_buffer = ByteBuffer::create_uninitialized(64);
+ ByteBuffer data_buffer;
+ if (!data_buffer.try_resize(64))
+ return ParseError::OutOfMemory;
+
while (!stream.has_any_error() && !stream.unreliable_eof()) {
char buf[16];
auto size = stream.read({ buf, 16 });
@@ -1413,6 +1416,8 @@ String parse_error_to_string(ParseError error)
return "The parser encountered an unimplemented feature";
case ParseError::HugeAllocationRequested:
return "Parsing caused an attempt to allocate a very big chunk of memory, likely malformed data";
+ case ParseError::OutOfMemory:
+ return "The parser hit an OOM condition";
case ParseError::ExpectedFloatingImmediate:
return "Expected a floating point immediate";
case ParseError::ExpectedSignedImmediate: