mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
LibJS: Fix crash when trying to get source range
Previously, source_range() could crash attempting to read from a null unrealized->source_code pointer. It looks like the previous behaviour here was to return a dummy source range, so this commit restores that. With this loading https://github.com/SerenityOS/serenity works again.
This commit is contained in:
parent
a5aabb7940
commit
95d69fcf74
Notes:
sideshowbarker
2024-07-17 18:38:54 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/95d69fcf74 Pull-request: https://github.com/SerenityOS/serenity/pull/19105
@ -17,9 +17,12 @@ namespace JS {
|
||||
|
||||
SourceRange const& TracebackFrame::source_range() const
|
||||
{
|
||||
if (auto* unrealized = source_range_storage.get_pointer<UnrealizedSourceRange>()) {
|
||||
if (auto* unrealized = source_range_storage.get_pointer<UnrealizedSourceRange>(); unrealized && unrealized->source_code) {
|
||||
auto source_range = unrealized->source_code->range_from_offsets(unrealized->start_offset, unrealized->end_offset);
|
||||
source_range_storage = move(source_range);
|
||||
} else {
|
||||
static auto dummy_source_range = SourceRange { .code = SourceCode::create(String {}, String {}), .start = {}, .end = {} };
|
||||
return dummy_source_range;
|
||||
}
|
||||
return source_range_storage.get<SourceRange>();
|
||||
}
|
||||
@ -69,8 +72,6 @@ ThrowCompletionOr<void> Error::install_error_cause(Value options)
|
||||
|
||||
void Error::populate_stack()
|
||||
{
|
||||
static auto dummy_source_range = SourceRange { .code = SourceCode::create(String {}, String {}), .start = {}, .end = {} };
|
||||
|
||||
auto& vm = this->vm();
|
||||
m_traceback.ensure_capacity(vm.execution_context_stack().size());
|
||||
for (ssize_t i = vm.execution_context_stack().size() - 1; i >= 0; i--) {
|
||||
|
Loading…
Reference in New Issue
Block a user