Просмотр исходного кода

- db_postgres_convert_rows needs to free the row_buf on all error conditions
- db_postgres_convert_rows now free all rows when a processing error happens
- as now all memory is freed in error condition in the later steps, we can
change the logic db_postgres_store_result to only free the result in this
case, this fixes one crash in a out of memory error condition
- sync error msg with mysql, remove unnecessary connection pointer output


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

Henning Westerholt 17 лет назад
Родитель
Сommit
d25ca3c1ae
2 измененных файлов с 5 добавлено и 2 удалено
  1. 2 2
      modules/db_postgres/km_dbase.c
  2. 3 0
      modules/db_postgres/km_res.c

+ 2 - 2
modules/db_postgres/km_dbase.c

@@ -413,8 +413,8 @@ int db_postgres_store_result(const db_con_t* _con, db_res_t** _r)
 			/* Successful completion of a command returning data
 			 * (such as a SELECT or SHOW). */
 			if (db_postgres_convert_result(_con, *_r) < 0) {
-				LM_ERR("%p Error returned from convert_result()\n", _con);
-				db_free_result(*_r);
+				LM_ERR("error while converting result\n");
+				pkg_free(*_r);
 				*_r = 0;
 				rc = -4;
 				break;

+ 3 - 0
modules/db_postgres/km_res.c

@@ -224,6 +224,8 @@ int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r)
 
 	if (db_allocate_rows(_r) < 0) {
 		LM_ERR("could not allocate rows\n");
+		LM_DBG("freeing row buffer at %p\n", row_buf);
+		pkg_free(row_buf);
 		return -2;
 	}
 
@@ -260,6 +262,7 @@ int db_postgres_convert_rows(const db_con_t* _h, db_res_t* _r)
 			}
 			LM_DBG("freeing row buffer at %p\n", row_buf);
 			pkg_free(row_buf);
+			db_free_rows(_r);
 			return -4;
 			/*
 			 * The following housekeeping may not be technically required, but it