From be527b19062389d2621a1e01b1b17e4aa8e80f1a Mon Sep 17 00:00:00 2001 From: jaybeepee Date: Thu, 14 Jul 2016 15:58:11 +0200 Subject: [PATCH] modules/ims_registrar_scscf: fix memory leak related to S-CSCF notification engine --- modules/ims_registrar_scscf/registrar_notify.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/ims_registrar_scscf/registrar_notify.c b/modules/ims_registrar_scscf/registrar_notify.c index 9e41593cfd7..ff2db72dcff 100644 --- a/modules/ims_registrar_scscf/registrar_notify.c +++ b/modules/ims_registrar_scscf/registrar_notify.c @@ -440,7 +440,7 @@ int can_subscribe_to_reg(struct sip_msg *msg, char *_t, char *str2) { int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presentity_uri, str *watcher_contact, str *explit_dereg_contact, int num_explit_dereg_contact) { impurecord_t* r; int num_impus; - str* impu_list; + str* impu_list = 0; int res = 0; udomain_t* udomain; @@ -483,7 +483,10 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presen LM_DBG("About to ceate notification"); create_notifications(_d, r_passed, presentity_uri, watcher_contact, impu_list, num_impus, event_type, explit_dereg_contact, num_explit_dereg_contact); - return 0; + if (impu_list) { + pkg_free(impu_list); + } + return 0; break; //richard: we only use reg unreg expired and refresh @@ -510,12 +513,18 @@ int event_reg(udomain_t* _d, impurecord_t* r_passed, int event_type, str *presen //TODO this should be a configurable module param if (ul.register_udomain(domain, &udomain) < 0) { LM_ERR("Unable to register usrloc domain....aborting\n"); - return 0; + if (impu_list) { + pkg_free(impu_list); + } + return 0; } LM_DBG("About to ceate notification"); create_notifications(_d, r_passed, presentity_uri, watcher_contact, impu_list, num_impus, event_type, explit_dereg_contact, num_explit_dereg_contact); - return 1; + if (impu_list) { + pkg_free(impu_list); + } + return 1; default: LM_ERR("ERR:event_reg: Unknown event %d\n", event_type);