2
0
Эх сурвалжийг харах

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 жил өмнө
parent
commit
a21750ff6f

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