mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-10-26 23:11:34 +03:00
LibJS: Don't "copy construct" temporary value in ThrowCompletionOr ctor
It was possible for the generic ThrowCompletionOr constructor to "copy-construct" a JS Object when instantiating a ThrowCompletionOr via e.g `return *object;`. This happened because it chose the Object(Object& prototype) constructor which will be removed in a subsequent commit. It was not easy to debug. As a first step towards avoiding this in the future, the generic ThrowCompletionOr constructor now takes the value as a const reference.
This commit is contained in:
parent
3ea1584f2e
commit
42b5c896e8
Notes:
sideshowbarker
2024-07-17 03:15:37 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/42b5c896e8 Pull-request: https://github.com/SerenityOS/serenity/pull/16487 Reviewed-by: https://github.com/linusg ✅
@ -268,9 +268,9 @@ public:
|
|||||||
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
|
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
|
||||||
// Disabled for POD types to avoid weird conversion shenanigans.
|
// Disabled for POD types to avoid weird conversion shenanigans.
|
||||||
template<typename WrappedValueType>
|
template<typename WrappedValueType>
|
||||||
ThrowCompletionOr(WrappedValueType value)
|
ThrowCompletionOr(WrappedValueType const& value)
|
||||||
requires(!IsPOD<ValueType>)
|
requires(!IsPOD<ValueType>)
|
||||||
: m_value(move(value))
|
: m_value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user