Module: sip-router
Branch: master
Commit: a21750ff6fcf87d8e3f54597bdd3f1171846e6cb
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a21750f…
Author: Alex Hermann <alex(a)speakup.nl>
Committer: Alex Hermann <alex(a)speakup.nl>
Date: Mon Jan 28 13:08:02 2013 +0100
modules/sqlops: Check if pv_spec is available before trying to use it.
Instead of segfaulting when the script writer has not specified enough PV
specs to hold all the query's result columns, bail out with an error message.
---
modules/sqlops/sql_api.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/modules/sqlops/sql_api.c b/modules/sqlops/sql_api.c
index 06bd35a..b5ce758 100644
--- a/modules/sqlops/sql_api.c
+++ b/modules/sqlops/sql_api.c
@@ -569,6 +569,10 @@ int sql_do_pvquery(struct sip_msg *msg, sql_con_t *con, pv_elem_t
*query,
pv = res;
for(j=0; j<RES_COL_N(db_res); j++)
{
+ if (pv == NULL) {
+ LM_ERR("Missing pv spec for column %d\n", j+1);
+ goto error;
+ }
if (db_val2pv_spec(msg, &RES_ROWS(db_res)[0].values[j], &pv->sname) != 0)
{
LM_ERR("Failed to convert value for column %.*s\n",
RES_NAMES(db_res)[j]->len, RES_NAMES(db_res)[j]->s);