-
Notifications
You must be signed in to change notification settings - Fork 56
Fix crash issues #1565
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
base: master
Are you sure you want to change the base?
Fix crash issues #1565
Changes from all commits
0cae91e
28c2bdf
63f3101
79bdaf1
6814077
3db1909
b2ca031
c936f4b
bb0e948
b20ae16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1265,7 +1265,13 @@ StringRef* Evaluator::EvaluatorResult::resultOrErrorToString(ContextRef* ctx) co | |
| if (isSuccessful()) { | ||
| return result->toStringWithoutException(ctx); | ||
| } else { | ||
| return ((ValueRef*)error.value())->toStringWithoutException(ctx); | ||
| // Check if error value is valid before dereferencing | ||
| // In some edge cases (e.g., nested eval throw with finally allocation), | ||
| // the error value might be invalid or null | ||
| if (error.hasValue()) { | ||
| return ((ValueRef*)error.value())->toStringWithoutException(ctx); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
| return StringRef::emptyString(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3308,7 +3308,7 @@ class ByteCodeBlock : public gc { | |
| context->m_locData->push_back(std::make_pair(start, idx)); | ||
| } | ||
|
|
||
| #ifndef NDEBUG | ||
| #if !defined(NDEBUG) && defined(ESCARGOT_DEBUGGER) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The preprocessor guard |
||
| const auto loc = computeNodeLOC(m_codeBlock->src(), m_codeBlock->functionStart(), idx); | ||
| ByteCodeLOC* bytecodeLoc = &reinterpret_cast<ByteCode*>(first)->m_loc; | ||
| bytecodeLoc->index = loc.index; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anchor on
if (error.hasValue()) {. Replace the nested if-else with a guard clause that returns early when the error is absent. This flattens the control flow, reduces indentation, and makes the success path more obvious. The semantics remain unchanged because the early return still yieldsStringRef::emptyString()whenerror.hasValue()is false.