src: fix crash in GetErrorSource() for invalid using syntax

Signed-off-by: semimikoh <ejffjeosms@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62770
Fixes: https://github.com/nodejs/node/issues/62767
Refs: https://github.com/tc39/test262
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
semimikoh authored and GitHub committed 2026-04-28 18:49:29 +02:00
1 parent 3d6584005c
commit 4247cd305b
1 file changed
+2 -4
+2 -4
View File
@@ -150,8 +150,7 @@ static std::string GetErrorSource(Isolate* isolate,
: 0;
int start = message->GetStartColumn();
int end = message->GetEndColumn();
if (start >= script_start) {
CHECK_GE(end, start);
if (start >= script_start && end >= script_start) {
start -= script_start;
end -= script_start;
}
@@ -161,8 +160,7 @@ static std::string GetErrorSource(Isolate* isolate,
CHECK_GT(buf.size(), 0);
*added_exception_line = true;
if (start > end ||
start < 0 ||
if (start > end || start < 0 || end < 0 ||
static_cast<size_t>(end) > sourceline.size()) {
return buf;
}