Issue #2089 - Use JS engine stack if necessary when reporting errors

Based-on: m-c 996060
This commit is contained in:
Martok 2023-01-21 02:13:01 +01:00 committed by roytam1
commit 6b50dd5d06
21 changed files with 209 additions and 69 deletions

View file

@ -408,12 +408,15 @@ ErrorCopier::~ErrorCopier()
{
RootedValue exc(cx);
if (cx->getPendingException(&exc) && exc.isObject() && exc.toObject().is<ErrorObject>()) {
RootedSavedFrame stack(cx, cx->getPendingExceptionStack());
cx->clearPendingException();
ac.reset();
Rooted<ErrorObject*> errObj(cx, &exc.toObject().as<ErrorObject>());
JSObject* copyobj = CopyErrorObject(cx, errObj);
if (copyobj)
cx->setPendingException(ObjectValue(*copyobj));
if (copyobj) {
RootedValue rootedCopy(cx, ObjectValue(*copyobj));
cx->setPendingException(rootedCopy, stack);
}
}
}
}