From 735e2002df293a48c2719eaa947dc68ac6be405a Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Wed, 22 Feb 2006 02:25:24 +0000 Subject: [PATCH] If the this object in a call is not an XPCNativeWrapper, ignore the call instead of crashing. bug 327686, r=brendan sr=bzbarsky --- js/src/xpconnect/src/XPCNativeWrapper.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/src/xpconnect/src/XPCNativeWrapper.cpp b/js/src/xpconnect/src/XPCNativeWrapper.cpp index 2f9ea19be1c..afc1716d2cf 100644 --- a/js/src/xpconnect/src/XPCNativeWrapper.cpp +++ b/js/src/xpconnect/src/XPCNativeWrapper.cpp @@ -928,6 +928,19 @@ XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsval id, JS_STATIC_DLL_CALLBACK(JSBool) XPC_NW_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { + if (!XPCNativeWrapper::IsNativeWrapper(cx, obj)) { + // If obj is not an XPCNativeWrapper, then someone's probably trying to call + // our prototype (i.e., XPCNativeWrapper.prototype()). In this case, it is + // safe to simply ignore the call, since that's what would happen anyway. + +#ifdef DEBUG + if (!JS_ObjectIsFunction(cx, obj)) { + NS_WARNING("Ignoring a call for a weird object"); + } +#endif + return JS_TRUE; + } + XPC_NW_BYPASS_TEST(cx, obj, call, (cx, obj, argc, argv, rval)); return JS_TRUE;