Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue#2445 Null Pointer Deref #2461

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/wast-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for ParseWatModule above to succeed without *m being set?

Would this work instead:

if (errors.length()) { 
  return Result::Error;
}
assert(*m);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't ParseWatModule also return a Result? probably a good idea to check that instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that sounds good. You can do something like this

if (Failed(ParseWatModule(lexer.get(), &m, &errors, options_)) { 
   for (const auto& error : errors) {
      ...
   }
   return Result::Error;
}
assert(errors.length == 0);

} else {
return Result::Error; // Handle the null case appropriately
}
*out_command = std::move(command);
break;
}
Expand Down
Loading