Bug 457310 - Don't potentially run code with an exception still on cx. r+sr=jst

This commit is contained in:
Blake Kaplan 2008-10-13 15:53:33 -07:00
Родитель f1c3c0f46e
Коммит 2f53c5e0d7
2 изменённых файлов: 23 добавлений и 1 удалений

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

@ -931,13 +931,15 @@ class JSAutoTempValueRooter
JS_POP_TEMP_ROOT(mContext, &mTvr);
}
protected:
JSContext *mContext;
private:
#ifndef AIX
static void *operator new(size_t);
static void operator delete(void *, size_t);
#endif
JSContext *mContext;
JSTempValueRooter mTvr;
};

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

@ -1397,6 +1397,25 @@ XPCConvert::ConstructException(nsresult rv, const char* message,
/********************************/
class AutoExceptionRestorer : public JSAutoTempValueRooter
{
public:
AutoExceptionRestorer(JSContext *cx, jsval v)
: JSAutoTempValueRooter(cx, v),
mVal(v)
{
JS_ClearPendingException(mContext);
}
~AutoExceptionRestorer()
{
JS_SetPendingException(mContext, mVal);
}
private:
jsval mVal;
};
// static
nsresult
XPCConvert::JSValToXPCException(XPCCallContext& ccx,
@ -1406,6 +1425,7 @@ XPCConvert::JSValToXPCException(XPCCallContext& ccx,
nsIException** exceptn)
{
JSContext* cx = ccx.GetJSContext();
AutoExceptionRestorer aer(cx, s);
if(!JSVAL_IS_PRIMITIVE(s))
{