瀏覽代碼

- prevent problems when a DB modules (like db_postgres) first calls
db_free_row (because of some problems in the data processing), and
then later db_free_result
- this could cause a double free, and also a crash because of null pointer
- reported from Bayan Towfiq, bayan at flowroute dot com
- fix also a similar problem in the db_free_columns function


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5418 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt 16 年之前
父節點
當前提交
fec76e8d58
共有 2 個文件被更改,包括 4 次插入0 次删除
  1. 2 0
      lib/srdb1/db_res.c
  2. 2 0
      lib/srdb1/db_row.c

+ 2 - 0
lib/srdb1/db_res.c

@@ -85,6 +85,8 @@ inline int db_free_columns(db_res_t* _r)
 			RES_NAMES(_r)[col] = NULL;
 			RES_NAMES(_r)[col] = NULL;
 		}
 		}
 	}
 	}
+	RES_COL_N(_r) = 0;
+
 	/* free names and types */
 	/* free names and types */
 	if (RES_NAMES(_r)) {
 	if (RES_NAMES(_r)) {
 		LM_DBG("freeing result names at %p\n", RES_NAMES(_r));
 		LM_DBG("freeing result names at %p\n", RES_NAMES(_r));

+ 2 - 0
lib/srdb1/db_row.c

@@ -90,6 +90,8 @@ inline int db_free_row(db_row_t* _r)
 				break;
 				break;
 		}
 		}
 	}
 	}
+	/* now as we freed all, set number of colums to zero again */
+	ROW_N(_r) = 0;
 
 
 	if (ROW_VALUES(_r)) {
 	if (ROW_VALUES(_r)) {
 		LM_DBG("freeing row values at %p\n", ROW_VALUES(_r));
 		LM_DBG("freeing row values at %p\n", ROW_VALUES(_r));