From 43c0254d91d5037ec649366b101ea91806b2c876 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Sep 2024 03:16:05 +0000 Subject: [PATCH 1/3] Fix issue#2445 Null Pointer Deref --- src/wast-parser.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wast-parser.cc b/src/wast-parser.cc index f950512f01..6d8c8166c2 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; } From 1e7da1f6dc9faa1c6ee9c9c2bc248291d94e4eab Mon Sep 17 00:00:00 2001 From: haruki3hhh <135201297+haruki3hhh@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:28:20 -0500 Subject: [PATCH 2/3] Update wast-parser.cc --- src/wast-parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 6d8c8166c2..897a7bdf59 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -3442,7 +3442,7 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) { if (m) { *module = std::move(*m.get()); } else { - return Result::Error; // Handle the null case appropriately + return Result::Error; // Handle the null case appropriately } *out_command = std::move(command); break; From 3bfe526b59c5db004d23a20314c9932eb67e9fd4 Mon Sep 17 00:00:00 2001 From: haruki3hhh <135201297+haruki3hhh@users.noreply.github.com> Date: Sun, 15 Sep 2024 10:57:49 -0500 Subject: [PATCH 3/3] Update error-quote-module.txt --- test/regress/error-quote-module.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/regress/error-quote-module.txt 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 ;;)