Browse Source

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).
Marius Zbihlei 15 years ago
parent
commit
1527516a4b
1 changed files with 5 additions and 3 deletions
  1. 5 3
      lib/srdb1/db_res.c

+ 5 - 3
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;