Skip to content

Commit

Permalink
purple: Fix multiple memory leaks in DB code
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-lavin committed Sep 19, 2016
1 parent 7289417 commit a361686
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/purple/mapping.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit a361686

Please sign in to comment.