From 345fd7d996e033da5efab85777e9e2967838ec7b Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 22 Jul 2009 20:47:52 +0000 Subject: [PATCH] add error checking on switch_core_db_column_text git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14323 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_spidermonkey_core_db.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 5dbea1c106..568d18557e 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 @@ -214,12 +214,15 @@ static JSBool db_fetch(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, return JS_TRUE; } for (x = 0; x < colcount; x++) { - switch_snprintf(code, sizeof(code), "~_dB_RoW_DaTa_[\"%s\"] = \"%s\"", - (char *) switch_core_db_column_name(dbo->stmt, x), (char *) switch_core_db_column_text(dbo->stmt, x)); - - eval_some_js(code, dbo->cx, dbo->obj, rval); - if (*rval == JS_FALSE) { - return JS_TRUE; + const char *var = (char *) switch_core_db_column_name(dbo->stmt, x); + const char *val = (char *) switch_core_db_column_text(dbo->stmt, x); + + if (var && val) { + switch_snprintf(code, sizeof(code), "~_dB_RoW_DaTa_[\"%s\"] = \"%s\"", var, val); + eval_some_js(code, dbo->cx, dbo->obj, rval); + if (*rval == JS_FALSE) { + return JS_TRUE; + } } }