Module: sip-router
Branch: master
Commit: edc78dfb148c22f0d256485193bbdb0185b76d2f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=edc78df…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Mar 24 10:12:26 2014 +0100
db_unixodbc: free local variables in case of errors or no result
- reported by Alex Villacís Lasso
---
modules/db_unixodbc/dbase.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/modules/db_unixodbc/dbase.c b/modules/db_unixodbc/dbase.c
index 61300a3..c37253f 100644
--- a/modules/db_unixodbc/dbase.c
+++ b/modules/db_unixodbc/dbase.c
@@ -332,6 +332,7 @@ int db_unixodbc_fetch_result(const db1_con_t* _h, db1_res_t** _r,
const int nrow
len = sizeof(db_row_t) * nrows;
RES_ROWS(*_r) = (struct db_row*)pkg_malloc(len);
if (!RES_ROWS(*_r)) {
+ pkg_free(temp_row);
LM_ERR("no memory left\n");
return -5;
}
@@ -359,6 +360,7 @@ int db_unixodbc_fetch_result(const db1_con_t* _h, db1_res_t** _r,
const int nrow
if (db_unixodbc_list_insert(&rowstart, &rows, columns, temp_row) < 0) {
LM_ERR("SQL result row insert failed\n");
+ pkg_free(RES_ROWS(*_r));
pkg_free(temp_row);
temp_row= NULL;
pkg_free(*_r);
@@ -380,6 +382,7 @@ int db_unixodbc_fetch_result(const db1_con_t* _h, db1_res_t** _r,
const int nrow
RES_ROW_N(*_r) = row_n;
if (!row_n) {
LM_DBG("no more rows to process for db fetch");
+ pkg_free(RES_ROWS(*_r));
RES_ROWS(*_r) = 0;
return 0;
}