From 27561c65609e4c8f40e03bad2b65e919f7f52bc7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 15 Jun 2007 17:05:20 +0000 Subject: [PATCH] Avoiding Initial SegFault *now with lycopene!* git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5373 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_spidermonkey/mod_spidermonkey.c | 17 ++++++----------- .../mod_spidermonkey/mod_spidermonkey.h | 7 +++++-- .../mod_spidermonkey_core_db.c | 2 +- .../mod_spidermonkey_etpan.c | 2 +- .../mod_spidermonkey_odbc.c | 2 +- .../mod_spidermonkey_skel.c | 2 +- .../mod_spidermonkey_teletone.c | 2 +- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index c9033b5a59..4e480b1476 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -45,10 +45,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown); SWITCH_MODULE_DEFINITION(mod_spidermonkey, mod_spidermonkey_load, mod_spidermonkey_shutdown, NULL); #define METHOD_SANITY_CHECK() do { \ -if (jss->sanity_code != SANITY_CODE_VAL) { \ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Object! Avoiding Initial SegFault!\n"); \ - return JS_TRUE; \ - } \ if (!jss || !jss->session) { \ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); \ *rval = BOOLEAN_TO_JSVAL(JS_FALSE); \ @@ -84,7 +80,7 @@ static struct { static JSClass global_class = { "Global", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub }; @@ -299,7 +295,7 @@ static JSBool request_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval JSClass request_class = { "Request", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, request_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, request_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, request_destroy, NULL, NULL, NULL, NULL }; @@ -604,7 +600,7 @@ static JSBool event_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval JSClass event_class = { "Event", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, event_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, event_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, event_destroy, NULL, NULL, NULL, event_construct }; @@ -2040,6 +2036,7 @@ static JSPropertySpec session_props[] = { {0} }; + static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * vp) { struct js_session *jss = JS_GetPrivate(cx, obj); @@ -2133,7 +2130,7 @@ static JSBool session_getProperty(JSContext * cx, JSObject * obj, jsval id, jsva JSClass session_class = { "Session", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, session_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, session_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, session_destroy, NULL, NULL, NULL, session_construct }; @@ -2149,7 +2146,6 @@ static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_sess jss->cx = cx; jss->obj = session_obj; jss->stack_depth = 0; - jss->sanity_code = SANITY_CODE_VAL; if ((JS_SetPrivate(cx, session_obj, jss) && JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) { return session_obj; @@ -2170,7 +2166,6 @@ static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsva memset(jss, 0, sizeof(*jss)); jss->cx = cx; jss->obj = obj; - jss->sanity_code = SANITY_CODE_VAL; switch_set_flag(jss, S_FREE); JS_SetPrivate(cx, obj, jss); @@ -2513,7 +2508,7 @@ static JSBool fileio_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval JSClass fileio_class = { "FileIO", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, fileio_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, fileio_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, fileio_destroy, NULL, NULL, NULL, fileio_construct }; diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h index daa7e78335..88a7f73ea3 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h @@ -122,7 +122,6 @@ struct sm_module_interface { typedef struct sm_module_interface sm_module_interface_t; typedef switch_status_t (*spidermonkey_init_t) (const sm_module_interface_t ** module_interface); -#define SANITY_CODE_VAL 424242 struct js_session { switch_core_session_t *session; JSContext *cx; @@ -132,9 +131,13 @@ struct js_session { JSFunction *on_hangup; int stack_depth; switch_channel_state_t hook_state; - int sanity_code; }; +JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp) +{ + return JS_FALSE; +} + SWITCH_END_EXTERN_C diff --git a/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c b/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c index 03e97ea384..57f344db63 100644 --- a/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c +++ b/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c @@ -268,7 +268,7 @@ static JSBool db_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * v JSClass db_class = { modname, JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, db_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, db_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, db_destroy, NULL, NULL, NULL, db_construct }; diff --git a/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c b/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c index a250099fa3..2c38e576ea 100644 --- a/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c +++ b/src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c @@ -216,7 +216,7 @@ static JSBool etpan_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval JSClass etpan_class = { modname, JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, etpan_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, etpan_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, etpan_destroy, NULL, NULL, NULL, etpan_construct }; diff --git a/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c b/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c index 7dca90b582..c4a92f322e 100644 --- a/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c +++ b/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c @@ -438,7 +438,7 @@ static JSBool odbc_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * JSClass odbc_class = { modname, JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, odbc_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, odbc_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, odbc_destroy, NULL, NULL, NULL, odbc_construct }; diff --git a/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c b/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c index 5bc8f6e004..0b7b8117ac 100644 --- a/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c +++ b/src/mod/languages/mod_spidermonkey_skel/mod_spidermonkey_skel.c @@ -74,7 +74,7 @@ static JSBool skel_getProperty(JSContext * cx, JSObject * obj, jsval id, jsval * JSClass skel_class = { modname, JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, skel_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, skel_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, skel_destroy, NULL, NULL, NULL, skel_construct }; diff --git a/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c b/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c index ac38c42862..5fda95dafa 100644 --- a/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c +++ b/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c @@ -331,7 +331,7 @@ static JSBool teletone_getProperty(JSContext * cx, JSObject * obj, jsval id, jsv JSClass teletone_class = { modname, JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_PropertyStub, teletone_getProperty, JS_PropertyStub, + JS_PropertyStub, JS_PropertyStub, teletone_getProperty, DEFAULT_SET_PROPERTY, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, teletone_destroy, NULL, NULL, NULL, teletone_construct };