diff --git a/src/wast-parser.cc b/src/wast-parser.cc index f950512f01..897a7bdf59 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -3439,7 +3439,11 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) { error.loc.offset, error.message.c_str()); } } - *module = std::move(*m.get()); + if (m) { + *module = std::move(*m.get()); + } else { + return Result::Error; // Handle the null case appropriately + } *out_command = std::move(command); break; } diff --git a/test/regress/error-quote-module.txt b/test/regress/error-quote-module.txt new file mode 100644 index 0000000000..3c42ee6173 --- /dev/null +++ b/test/regress/error-quote-module.txt @@ -0,0 +1,8 @@ +;;; TOOL: wat2wasm +;;; ERROR: 1 +(module quote "\7c") +(;; STDERR ;;; +out/test/regress/error-quote-module.txt:3:2: error: error in quoted module: @0x100000001: unexpected token "|", expected a module field or a module. +(module quote "\7c") + ^^^^^^ +;;; STDERR ;;)