Module: kamailio
Branch: master
Commit: 9c1b55e90648f81514bdf2570eeeae83bf46dfff
URL:
https://github.com/kamailio/kamailio/commit/9c1b55e90648f81514bdf2570eeeae8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2016-09-19T23:04:38+02:00
Merge pull request #788 from phil-lavin/mem-leaks
Fix memory leaks in presence and purple
---
Modified: modules/presence/presentity.c
Modified: modules/purple/mapping.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9c1b55e90648f81514bdf2570eeeae8…
Patch:
https://github.com/kamailio/kamailio/commit/9c1b55e90648f81514bdf2570eeeae8…
---
diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c
index d81b90e..e601153 100644
--- a/modules/presence/presentity.c
+++ b/modules/presence/presentity.c
@@ -396,9 +396,11 @@ int delete_presentity_if_dialog_id_exists(presentity_t* presentity,
char* dialog
if(result == NULL)
return -3;
- // No results from query definitely means no dialog exists
- if (result->n <= 0)
+ /* no results from query definitely means no dialog exists */
+ if (result->n <= 0) {
+ pa_dbf.free_result(pa_db, result);
return 0;
+ }
// Loop the rows returned from the DB
for (i=0; i < result->n; i++)
diff --git a/modules/purple/mapping.c b/modules/purple/mapping.c
index e1aa00e..bbdb69f 100644
--- a/modules/purple/mapping.c
+++ b/modules/purple/mapping.c
@@ -133,8 +133,11 @@ char *find_sip_user(char *extern_user) {
if (result == NULL)
return NULL;
- if (result->n <= 0)
+
+ if (result->n <= 0) {
+ pa_dbf.free_result(pa_db, result);
return NULL;
+ }
row = &result->rows[0];
row_vals = ROW_VALUES(row);
@@ -208,6 +211,7 @@ extern_account_t *find_accounts(char* sip_user, int* count) {
return NULL;
}
if (result->n <= 0) {
+ pa_dbf.free_result(pa_db, result);
LM_ERR("result count = %d\n", result->n);
return NULL;
}
@@ -290,8 +294,11 @@ extern_user_t *find_users(char *sip_user, int* count) {
if (result == NULL)
return NULL;
- if (result->n <= 0)
+
+ if (result->n <= 0) {
+ pa_dbf.free_result(pa_db, result);
return NULL;
+ }
users = (extern_user_t*) pkg_malloc(sizeof(extern_user_t)*result->n);