浏览代码

purple: Fix multiple memory leaks in DB code

Phil Lavin 9 年之前
父节点
当前提交
a361686b2c
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      modules/purple/mapping.c

+ 9 - 2
modules/purple/mapping.c

@@ -133,8 +133,11 @@ char *find_sip_user(char *extern_user) {
 	
 	
 	if (result == NULL)
 	if (result == NULL)
 		return NULL;
 		return NULL;
-	if (result->n <= 0)
+
+	if (result->n <= 0) {
+		pa_dbf.free_result(pa_db, result);
 		return NULL;
 		return NULL;
+	}
 
 
 	row = &result->rows[0];
 	row = &result->rows[0];
 	row_vals = ROW_VALUES(row);
 	row_vals = ROW_VALUES(row);
@@ -208,6 +211,7 @@ extern_account_t *find_accounts(char* sip_user, int* count) {
 		return NULL;
 		return NULL;
 	}
 	}
 	if (result->n <= 0) {
 	if (result->n <= 0) {
+		pa_dbf.free_result(pa_db, result);
 		LM_ERR("result count = %d\n", result->n);
 		LM_ERR("result count = %d\n", result->n);
 		return NULL;
 		return NULL;
 	}
 	}
@@ -290,8 +294,11 @@ extern_user_t *find_users(char *sip_user, int* count) {
 
 
 	if (result == NULL)
 	if (result == NULL)
 		return NULL;
 		return NULL;
-	if (result->n <= 0)
+
+	if (result->n <= 0) {
+		pa_dbf.free_result(pa_db, result);
 		return NULL;
 		return NULL;
+	}
 
 
 	users = (extern_user_t*) pkg_malloc(sizeof(extern_user_t)*result->n);
 	users = (extern_user_t*) pkg_malloc(sizeof(extern_user_t)*result->n);