Skip to content

Truly independent web browser

LibJS: Stop sharing one SourceCode for frames without a source range

Andreas Kling5df9770211af
diff --git a/Libraries/LibJS/Runtime/ErrorData.cpp b/Libraries/LibJS/Runtime/ErrorData.cpp
index 12d905dc1ba..66038a57369 100644
--- a/Libraries/LibJS/Runtime/ErrorData.cpp
+++ b/Libraries/LibJS/Runtime/ErrorData.cpp
@@ -4,7 +4,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/NeverDestroyed.h>
#include <LibJS/EmbeddingABIConversions.h>
#include <LibJS/Runtime/ErrorData.h>
#include <LibJS/Runtime/VM.h>
@@ -19,16 +18,10 @@ static JSErrorData const* error_data_to_abi(ErrorData const& error_data)
return reinterpret_cast<JSErrorData const*>(&error_data);
}
-static SourceRange const& source_range_of_a_frame_without_one()
-{
- static NeverDestroyed<SourceRange> source_range { SourceRange { SourceCode::create({}, Utf16String {}), {} } };
- return *source_range;
-}
-
-SourceRange const& TracebackFrame::source_range() const
+SourceRange TracebackFrame::source_range() const
{
if (!cached_source_range.has_value())
- return source_range_of_a_frame_without_one();
+ return SourceRange { SourceCode::create({}, Utf16String {}), {} };
return *cached_source_range;
}
diff --git a/Libraries/LibJS/Runtime/ErrorData.h b/Libraries/LibJS/Runtime/ErrorData.h
index 24a9c977b9f..4f2b7858cac 100644
--- a/Libraries/LibJS/Runtime/ErrorData.h
+++ b/Libraries/LibJS/Runtime/ErrorData.h
@@ -24,7 +24,7 @@ namespace JS {
struct JS_API TracebackFrame {
Utf16String function_name;
- [[nodiscard]] SourceRange const& source_range() const;
+ [[nodiscard]] SourceRange source_range() const;
Optional<SourceRange> cached_source_range;
};