Skip to content

maple: parse preg numbers with from_chars instead of stoi - #1

Open
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/fix-maple-preg-stoi-from-chars
Open

maple: parse preg numbers with from_chars instead of stoi#1
tonycoder-hub wants to merge 1 commit into
openharmony:masterfrom
tonycoder-hub:cursor/fix-maple-preg-stoi-from-chars

Conversation

@tonycoder-hub

Copy link
Copy Markdown

Summary

Formal names that start with a digit were passed to std::stoi. Empty front() is UB; overflow (2147483648) throws.

Parse via std::from_chars and treat failure as a regular var formal.

Test plan

  • Host+asan locally: empty / overflow preg names no longer throw; valid "1" still becomes a preg.
  • Local harness (not in this PR): g++ -std=c++17 -fsanitize=address,undefined -Iecmascript/compiler/codegen/maple/maple_ir/include ecmascript/compiler/codegen/maple/maple_ir/src/parse_preg_no_host_test.cpp && ./a.out

Signed-off-by: Tony Coder 407243179@qq.com

Formal names that start with a digit were passed to std::stoi.
Empty front() is UB; overflow (2147483648) throws. Parse via
from_chars and treat failure as a regular var formal.

Signed-off-by: Tony Coder <407243179@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant