Bug 1615022 part 3. Disallow conversion of CopyableErrorResult to ErrorResult&. r=farre

This keeps us from passing it to functions that are planning to throw on the
ErrorResult and might throw a JS exception on it.

Differential Revision: https://phabricator.services.mozilla.com/D62633

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2020-02-14 10:19:05 +00:00
Родитель 6c66fa85a4
Коммит f781fa6569
3 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -95,8 +95,10 @@ struct ParamTraits<mozilla::CopyableErrorResult> {
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
mozilla::ErrorResult& ref = static_cast<mozilla::ErrorResult&>(*aResult);
return ParamTraits<mozilla::ErrorResult>::Read(aMsg, aIter, &ref);
// We can't cast *aResult to ErrorResult&, so cheat and just cast
// to ErrorResult*.
return ParamTraits<mozilla::ErrorResult>::Read(
aMsg, aIter, reinterpret_cast<mozilla::ErrorResult*>(aResult));
}
};

Просмотреть файл

@ -792,6 +792,11 @@ class CopyableErrorResult
return *this;
}
// Disallow implicit converstion to non-const ErrorResult&, because that would
// allow people to throw exceptions on us while bypassing our checks for JS
// exceptions.
operator ErrorResult&() = delete;
// Allow conversion to ErrorResult&& so we can move out of ourselves into
// an ErrorResult.
operator ErrorResult &&() && {

Просмотреть файл

@ -453,7 +453,7 @@ RefPtr<ClientOpPromise> ClientOpenWindowInCurrentProcess(
#endif // MOZ_WIDGET_ANDROID
RefPtr<BrowsingContext> bc;
CopyableErrorResult rv;
ErrorResult rv;
OpenWindow(aArgs, getter_AddRefs(bc), rv);
nsCOMPtr<nsPIDOMWindowOuter> outerWindow(bc->GetDOMWindow());