From 51e901ec19577090a6c2ca15158dce67a1f4e845 Mon Sep 17 00:00:00 2001 From: agree Date: Sun, 5 Jan 2025 20:20:45 -0500 Subject: [PATCH] fix memory leak caused by previous commit https://github.com/fusionpbx/freeswitch/commit/25b2b7be7ecaca912d73ff8302be00c59638c8a3 --- src/mod/endpoints/mod_sofia/sofia_presence.c | 36 +++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 1b7b69ca781..bbf03a7df16 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -3772,27 +3772,35 @@ void sofia_presence_handle_sip_i_subscribe(int status, if (!strcmp("as-feature-event", event)) { char key[128] = ""; + uint8_t res; switch_event_t *v_event = NULL; - if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, sizeof(key), &v_event, NULL, NULL, NULL)) { - if (v_event) { - switch_event_destroy(&v_event); - } + res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, sizeof(key), &v_event, NULL, NULL, NULL); + + if (v_event) { + switch_event_destroy(&v_event); + } + + if (res) { goto end; } } else if (sofia_test_pflag(profile, PFLAG_AUTH_SUBSCRIPTIONS)) { char keybuf[128] = ""; char *key; size_t keylen; + uint8_t res; switch_event_t *v_event = NULL; key = keybuf; keylen = sizeof(keybuf); - if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL)) { - if (v_event) { - switch_event_destroy(&v_event); - } + res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL); + + if (v_event) { + switch_event_destroy(&v_event); + } + + if (res) { goto end; } } @@ -4739,15 +4747,19 @@ void sofia_presence_handle_sip_i_message(int status, char keybuf[128] = ""; char *key; size_t keylen; + uint8_t res; switch_event_t *v_event = NULL; key = keybuf; keylen = sizeof(keybuf); - if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL)) { - if (v_event) { - switch_event_destroy(&v_event); - } + res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL); + + if (v_event) { + switch_event_destroy(&v_event); + } + + if (res) { goto end; }