From 4247cd305b4f6d79912caaaf105faad324d3bc83 Mon Sep 17 00:00:00 2001 From: semimikoh <123785695+semimikoh@users.noreply.github.com> Date: Wed, 29 Apr 2026 01:49:29 +0900 Subject: [PATCH] src: fix crash in GetErrorSource() for invalid using syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: semimikoh 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é Reviewed-By: Daeyeon Jeong Reviewed-By: Chengzhong Wu --- src/node_errors.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node_errors.cc b/src/node_errors.cc index a2ece94b938..74326496132 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -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(end) > sourceline.size()) { return buf; }