Module: sip-router Branch: kamailio_3.0 Commit: 79352b61841907f08bf7ca994acf814b2a5a6615 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=79352b61...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Marius Zbihlei marius.zbihlei@1and1.ro Date: Tue Apr 27 15:40:10 2010 +0300
lib/srdb1 The RES_ROW(res) was not checked to be NULL before being used
This caused a crash in the case that RES_ROW_N(res) was > 0, and RES_ROW was NULL (like a pkg_malloc going bad in a OOM scenario).
---
lib/srdb1/db_res.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/srdb1/db_res.c b/lib/srdb1/db_res.c index 3581021..8d2146e 100644 --- a/lib/srdb1/db_res.c +++ b/lib/srdb1/db_res.c @@ -49,10 +49,12 @@ inline int db_free_rows(db1_res_t* _r) LM_ERR("invalid parameter value\n"); return -1; } - LM_DBG("freeing %d rows\n", RES_ROW_N(_r));
- for(i = 0; i < RES_ROW_N(_r); i++) { - db_free_row(&(RES_ROWS(_r)[i])); + if(RES_ROWS(_r)){ + LM_DBG("freeing %d rows\n", RES_ROW_N(_r)); + for(i = 0; i < RES_ROW_N(_r); i++) { + db_free_row(&(RES_ROWS(_r)[i])); + } } RES_ROW_N(_r) = 0;