From 958d0a72030227bf3133c8b99c7c670bcdbc7636 Mon Sep 17 00:00:00 2001 From: Keith Winstein <208955+keithw@users.noreply.github.com> Date: Mon, 11 Nov 2024 21:10:52 -0800 Subject: wast-parser.cc: Fix a crash from failing (module quote ...) (#2509) --- src/wast-parser.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wast-parser.cc b/src/wast-parser.cc index e3606b7c..0868a217 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -3481,7 +3481,7 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) { std::unique_ptr<Module> m; std::unique_ptr<WastLexer> lexer = WastLexer::CreateBufferLexer( filename, qsm->data.data(), qsm->data.size(), &errors); - ParseWatModule(lexer.get(), &m, &errors, options_); + auto result = ParseWatModule(lexer.get(), &m, &errors, options_); for (const auto& error : errors) { if (error.loc.offset == kInvalidOffset) { Error(qsm->loc, "error in quoted module: %s", error.message.c_str()); @@ -3490,7 +3490,9 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) { error.loc.offset, error.message.c_str()); } } - *module = std::move(*m.get()); + if (Succeeded(result)) { + *module = std::move(*m.get()); + } *out_command = std::move(command); break; } -- cgit v1.2.3