Skip to content

Commit 48bcd06

Browse files
authored
fix memory leak caused by previous commit (#7)
25b2b7b
1 parent ff4660d commit 48bcd06

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/mod/endpoints/mod_sofia/sofia_presence.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,27 +3772,35 @@ void sofia_presence_handle_sip_i_subscribe(int status,
37723772

37733773
if (!strcmp("as-feature-event", event)) {
37743774
char key[128] = "";
3775+
uint8_t res;
37753776
switch_event_t *v_event = NULL;
37763777

3777-
if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, sizeof(key), &v_event, NULL, NULL, NULL)) {
3778-
if (v_event) {
3779-
switch_event_destroy(&v_event);
3780-
}
3778+
res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, sizeof(key), &v_event, NULL, NULL, NULL);
3779+
3780+
if (v_event) {
3781+
switch_event_destroy(&v_event);
3782+
}
3783+
3784+
if (res) {
37813785
goto end;
37823786
}
37833787
} else if (sofia_test_pflag(profile, PFLAG_AUTH_SUBSCRIPTIONS)) {
37843788
char keybuf[128] = "";
37853789
char *key;
37863790
size_t keylen;
3791+
uint8_t res;
37873792
switch_event_t *v_event = NULL;
37883793

37893794
key = keybuf;
37903795
keylen = sizeof(keybuf);
37913796

3792-
if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL)) {
3793-
if (v_event) {
3794-
switch_event_destroy(&v_event);
3795-
}
3797+
res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL);
3798+
3799+
if (v_event) {
3800+
switch_event_destroy(&v_event);
3801+
}
3802+
3803+
if (res) {
37963804
goto end;
37973805
}
37983806
}
@@ -4739,15 +4747,19 @@ void sofia_presence_handle_sip_i_message(int status,
47394747
char keybuf[128] = "";
47404748
char *key;
47414749
size_t keylen;
4750+
uint8_t res;
47424751
switch_event_t *v_event = NULL;
47434752

47444753
key = keybuf;
47454754
keylen = sizeof(keybuf);
47464755

4747-
if (sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL)) {
4748-
if (v_event) {
4749-
switch_event_destroy(&v_event);
4750-
}
4756+
res = sofia_reg_handle_register(nua, profile, nh, sip, de, REG_INVITE, key, (uint32_t)keylen, &v_event, NULL, NULL, NULL);
4757+
4758+
if (v_event) {
4759+
switch_event_destroy(&v_event);
4760+
}
4761+
4762+
if (res) {
47514763
goto end;
47524764
}
47534765

0 commit comments

Comments
 (0)