浏览代码

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.
Alex Hermann 12 年之前
父节点
当前提交
a21750ff6f
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      modules/sqlops/sql_api.c

+ 4 - 0
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);