зеркало из https://github.com/mozilla/pjs.git
Bug 498543 - Null-checking JS_THIS_OBJECT Results. r=jwalden
This commit is contained in:
Родитель
4427e37fa9
Коммит
7ab6ae09ca
|
@ -139,6 +139,9 @@ JSBool
|
|||
EventTarget::AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EventTarget* self = GetPrivate(aCx, obj);
|
||||
if (!self) {
|
||||
|
@ -167,6 +170,9 @@ JSBool
|
|||
EventTarget::RemoveEventListener(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EventTarget* self = GetPrivate(aCx, obj);
|
||||
if (!self) {
|
||||
|
@ -195,6 +201,9 @@ JSBool
|
|||
EventTarget::DispatchEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EventTarget* self = GetPrivate(aCx, obj);
|
||||
if (!self) {
|
||||
|
|
|
@ -317,6 +317,9 @@ private:
|
|||
StopPropagation(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Event* event = GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
if (!event) {
|
||||
|
@ -332,6 +335,9 @@ private:
|
|||
StopImmediatePropagation(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Event* event = GetInstancePrivate(aCx, obj, sFunctions[3].name);
|
||||
if (!event) {
|
||||
|
@ -347,6 +353,9 @@ private:
|
|||
PreventDefault(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Event* event = GetInstancePrivate(aCx, obj, sFunctions[1].name);
|
||||
if (!event) {
|
||||
|
@ -367,6 +376,9 @@ private:
|
|||
InitEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Event* event = GetInstancePrivate(aCx, obj, sFunctions[2].name);
|
||||
if (!event) {
|
||||
|
@ -627,6 +639,9 @@ private:
|
|||
InitMessageEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageEvent* event = GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
if (!event) {
|
||||
|
@ -823,6 +838,9 @@ private:
|
|||
InitErrorEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ErrorEvent* event = GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
if (!event) {
|
||||
|
@ -1010,6 +1028,9 @@ private:
|
|||
InitProgressEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProgressEvent* event = GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
if (!event) {
|
||||
|
|
|
@ -122,6 +122,9 @@ private:
|
|||
ToString(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JSClass* classPtr;
|
||||
if (!obj || ((classPtr = JS_GET_CLASS(aCx, obj)) != &sClass)) {
|
||||
|
|
|
@ -185,6 +185,9 @@ private:
|
|||
MozSlice(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIDOMBlob* blob = GetInstancePrivate(aCx, obj, "mozSlice");
|
||||
if (!blob) {
|
||||
|
|
|
@ -180,6 +180,9 @@ private:
|
|||
ReadAsArrayBuffer(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileReaderSyncPrivate* fileReader =
|
||||
GetInstancePrivate(aCx, obj, "readAsArrayBuffer");
|
||||
|
@ -224,6 +227,9 @@ private:
|
|||
ReadAsDataURL(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileReaderSyncPrivate* fileReader =
|
||||
GetInstancePrivate(aCx, obj, "readAsDataURL");
|
||||
|
@ -261,6 +267,9 @@ private:
|
|||
ReadAsBinaryString(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileReaderSyncPrivate* fileReader =
|
||||
GetInstancePrivate(aCx, obj, "readAsBinaryString");
|
||||
|
@ -298,6 +307,9 @@ private:
|
|||
ReadAsText(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileReaderSyncPrivate* fileReader =
|
||||
GetInstancePrivate(aCx, obj, "readAsText");
|
||||
|
|
|
@ -267,6 +267,9 @@ private:
|
|||
Terminate(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*& name = sFunctions[0].name;
|
||||
WorkerPrivate* worker = GetInstancePrivate(aCx, obj, name);
|
||||
|
@ -281,6 +284,9 @@ private:
|
|||
PostMessage(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*& name = sFunctions[1].name;
|
||||
WorkerPrivate* worker = GetInstancePrivate(aCx, obj, name);
|
||||
|
|
|
@ -386,6 +386,9 @@ private:
|
|||
Close(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
if (!scope) {
|
||||
|
@ -399,6 +402,9 @@ private:
|
|||
ImportScripts(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[1].name);
|
||||
if (!scope) {
|
||||
|
@ -416,6 +422,9 @@ private:
|
|||
SetTimeout(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[2].name);
|
||||
if (!scope) {
|
||||
|
@ -434,6 +443,9 @@ private:
|
|||
ClearTimeout(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[3].name);
|
||||
if (!scope) {
|
||||
|
@ -452,6 +464,9 @@ private:
|
|||
SetInterval(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[4].name);
|
||||
if (!scope) {
|
||||
|
@ -470,6 +485,9 @@ private:
|
|||
ClearInterval(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, sFunctions[5].name);
|
||||
if (!scope) {
|
||||
|
@ -487,8 +505,12 @@ private:
|
|||
static JSBool
|
||||
Dump(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
if (!GetInstancePrivate(aCx, JS_THIS_OBJECT(aCx, aVp),
|
||||
sFunctions[6].name)) {
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetInstancePrivate(aCx, obj, sFunctions[6].name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -513,8 +535,12 @@ private:
|
|||
static JSBool
|
||||
AtoB(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
if (!GetInstancePrivate(aCx, JS_THIS_OBJECT(aCx, aVp),
|
||||
sFunctions[7].name)) {
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetInstancePrivate(aCx, obj, sFunctions[7].name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -535,8 +561,12 @@ private:
|
|||
static JSBool
|
||||
BtoA(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
if (!GetInstancePrivate(aCx, JS_THIS_OBJECT(aCx, aVp),
|
||||
sFunctions[8].name)) {
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetInstancePrivate(aCx, obj, sFunctions[8].name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -754,6 +784,9 @@ private:
|
|||
PostMessage(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*& name = sFunctions[0].name;
|
||||
DedicatedWorkerGlobalScope* scope = GetInstancePrivate(aCx, obj, name);
|
||||
|
|
|
@ -605,6 +605,9 @@ private:
|
|||
Abort(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[0].name);
|
||||
|
@ -619,6 +622,9 @@ private:
|
|||
GetAllResponseHeaders(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[1].name);
|
||||
|
@ -639,6 +645,9 @@ private:
|
|||
GetResponseHeader(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[2].name);
|
||||
|
@ -675,6 +684,9 @@ private:
|
|||
Open(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[3].name);
|
||||
|
@ -698,6 +710,9 @@ private:
|
|||
Send(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[4].name);
|
||||
|
@ -714,6 +729,9 @@ private:
|
|||
SendAsBinary(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[5].name);
|
||||
|
@ -744,6 +762,9 @@ private:
|
|||
SetRequestHeader(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[6].name);
|
||||
|
@ -764,6 +785,9 @@ private:
|
|||
OverrideMimeType(JSContext* aCx, uintN aArgc, jsval* aVp)
|
||||
{
|
||||
JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XMLHttpRequestPrivate* priv =
|
||||
GetInstancePrivate(aCx, obj, sFunctions[7].name);
|
||||
|
|
|
@ -3904,8 +3904,11 @@ FunctionWrapper(JSContext *cx, uintN argc, jsval *vp)
|
|||
return false;
|
||||
NS_ASSERTION(JSVAL_IS_OBJECT(v), "weird function");
|
||||
|
||||
return JS_CallFunctionValue(cx, JS_THIS_OBJECT(cx, vp), v,
|
||||
argc, JS_ARGV(cx, vp), vp);
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_CallFunctionValue(cx, obj, v, argc, JS_ARGV(cx, vp), vp);
|
||||
}
|
||||
|
||||
JSBool
|
||||
|
|
|
@ -450,7 +450,7 @@ static JSBool
|
|||
XrayToString(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSObject *wrapper = JS_THIS_OBJECT(cx, vp);
|
||||
if (!IsWrapper(wrapper) || !WrapperFactory::IsXrayWrapper(wrapper)) {
|
||||
if (!wrapper || !IsWrapper(wrapper) || !WrapperFactory::IsXrayWrapper(wrapper)) {
|
||||
JS_ReportError(cx, "XrayToString called on an incompatible object");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -66,9 +66,13 @@ stepFunc(JSContext *aCtx,
|
|||
{
|
||||
nsCOMPtr<nsIXPConnect> xpc(Service::getXPConnect());
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
nsresult rv = xpc->GetWrappedNativeOfJSObject(
|
||||
aCtx, JS_THIS_OBJECT(aCtx, _vp), getter_AddRefs(wrapper)
|
||||
);
|
||||
JSObject *obj = JS_THIS_OBJECT(aCtx, _vp);
|
||||
if (!obj) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
xpc->GetWrappedNativeOfJSObject(aCtx, obj, getter_AddRefs(wrapper));
|
||||
if (NS_FAILED(rv)) {
|
||||
::JS_ReportError(aCtx, "mozIStorageStatement::step() could not obtain native statement");
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -217,6 +217,10 @@ JSHistogram_Add(JSContext *cx, uintN argc, jsval *vp)
|
|||
|
||||
if (TelemetryImpl::CanRecord()) {
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
|
||||
if (h->histogram_type() == Histogram::BOOLEAN_HISTOGRAM)
|
||||
h->Add(!!value);
|
||||
|
@ -230,6 +234,10 @@ JSBool
|
|||
JSHistogram_Snapshot(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
|
||||
JSObject *snapshot = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
if (!snapshot)
|
||||
|
|
Загрузка…
Ссылка в новой задаче