Bug 1248948 - Don't pass non-SavedFrame objects to SavedFrame JSAPI functions; r=tromey r=evilpie

This commit is contained in:
Nick Fitzgerald 2016-04-05 13:51:00 +02:00
Родитель e725884022
Коммит 01cfd1d6c6
3 изменённых файлов: 22 добавлений и 1 удалений

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

@ -62,7 +62,8 @@ public:
return;
}
if (!JS::CopyAsyncStack(aCx, asyncStack, asyncCause, &parentFrame, 0)) {
if (JS::IsSavedFrame(asyncStack) &&
!JS::CopyAsyncStack(aCx, asyncStack, asyncCause, &parentFrame, 0)) {
JS_ClearPendingException(aCx);
} else {
stackFrame.mAsyncParent = parentFrame;

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

@ -5996,6 +5996,13 @@ GetSavedFrameParent(JSContext* cx, HandleObject savedFrame, MutableHandleObject
extern JS_PUBLIC_API(bool)
BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp, size_t indent = 0);
/**
* Return true iff the given object is either a SavedFrame object or wrapper
* around a SavedFrame object, and it is not the SavedFrame.prototype object.
*/
extern JS_PUBLIC_API(bool)
IsSavedFrame(JSObject* obj);
} /* namespace JS */

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

@ -930,6 +930,19 @@ BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp,
return true;
}
JS_PUBLIC_API(bool)
IsSavedFrame(JSObject* obj)
{
if (!obj)
return false;
JSObject* unwrapped = CheckedUnwrap(obj);
if (!unwrapped)
return false;
return js::SavedFrame::isSavedFrameAndNotProto(*unwrapped);
}
} /* namespace JS */
namespace js {