@@ -491,10 +491,15 @@ int db_val2pv_spec(struct sip_msg* msg, db_val_t *dbval, pv_spec_t *pvs)
if (pv_set_spec_value(msg, pvs, 0, &pv) != 0)
{
LM_ERR("Failed to add value to spec\n");
- if (pv.flags == PV_VAL_STR)
+ if (pv.flags == PV_VAL_STR && pv.rs.len > 0)
pkg_free(pv.rs.s);
return -1;
}
+ /* free string memory */
+ if (pv.flags == PV_VAL_STR && pv.rs.len > 0) {
+ pkg_free(pv.rs.s);
+ }
+
return 0;
@@ -208,7 +208,10 @@ int db_print_set(const db1_con_t* _c, char* _b, const int _l,
/**
- * Convert db_val to pv_spec_t
+ * Convert db_val_t to pv_spec_t
+ *
+ * On success, when the PV type is string and longer than 0 chars,
+ * the string must be freed by the caller after use.
*
* \param msg sip msg structure
* \param dbval database value