Module: kamailio
Branch: master
Commit: d2fa6939e3ba075beb82d173c5d1a7330341c7d0
URL:
https://github.com/kamailio/kamailio/commit/d2fa6939e3ba075beb82d173c5d1a73…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-07-31T15:54:27+02:00
pua: free in case of errors
---
Modified: src/modules/pua/add_events.c
Modified: src/modules/pua/send_publish.c
Modified: src/modules/pua/send_subscribe.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d2fa6939e3ba075beb82d173c5d1a73…
Patch:
https://github.com/kamailio/kamailio/commit/d2fa6939e3ba075beb82d173c5d1a73…
---
diff --git a/src/modules/pua/add_events.c b/src/modules/pua/add_events.c
index f4a9c8ebed..ce94d5a842 100644
--- a/src/modules/pua/add_events.c
+++ b/src/modules/pua/add_events.c
@@ -150,6 +150,7 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver,
str** tuple_pa
LM_ERR("No more memory\n");
goto error;
}
+ alloc_tuple = 1;
tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
if(tuple->s== NULL)
{
@@ -160,7 +161,6 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver,
str** tuple_pa
tuple->len= tuple_id_len;
*tuple_param= tuple;
- alloc_tuple= 1;
LM_DBG("allocated tuple_id\n\n");
}
@@ -252,12 +252,10 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver,
str** tuple_pa
xmlFreeDoc(doc);
if(body)
pkg_free(body);
- if(tuple && alloc_tuple)
- {
+ if(tuple && alloc_tuple) {
if(tuple->s)
pkg_free(tuple->s);
pkg_free(tuple);
- tuple= NULL;
}
return -1;
diff --git a/src/modules/pua/send_publish.c b/src/modules/pua/send_publish.c
index fc5f2f1918..5bd13e0b59 100644
--- a/src/modules/pua/send_publish.c
+++ b/src/modules/pua/send_publish.c
@@ -457,7 +457,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params
*ps)
return;
error:
- if(*ps->param)
+ if(ps->param && *ps->param)
{
shm_free(*ps->param);
*ps->param= NULL;
diff --git a/src/modules/pua/send_subscribe.c b/src/modules/pua/send_subscribe.c
index ff1f5bad23..89b597a77a 100644
--- a/src/modules/pua/send_subscribe.c
+++ b/src/modules/pua/send_subscribe.c
@@ -980,6 +980,7 @@ int send_subscribe(subs_info_t* subs)
if(str_hdr== NULL || str_hdr->s== NULL)
{
LM_ERR("while building extra headers\n");
+ if(str_hdr) pkg_free(str_hdr);
return -1;
}