[Asterisk-code-review] res pjsip/location: Fix memory leak in permanent uri handler (asterisk[master])
George Joseph
asteriskteam at digium.com
Fri May 29 16:23:50 CDT 2015
George Joseph has uploaded a new change for review.
https://gerrit.asterisk.org/548
Change subject: res_pjsip/location: Fix memory leak in permanent_uri_handler
......................................................................
res_pjsip/location: Fix memory leak in permanent_uri_handler
When permanent_uri_handler was creating the contact status
object for each contact, it wasn't unreffing it at the
end of the loop.
ASTERISK-25141 #close
Reported-by: Corey Farrell
Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12
---
M res/res_pjsip/location.c
1 file changed, 3 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/48/548/1
diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 887053b..9b50fee 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -353,7 +353,8 @@
contacts = ast_strdupa(var->value);
while ((contact_uri = strsep(&contacts, ","))) {
- struct ast_sip_contact *contact;
+ RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_sip_contact_status *, status, NULL, ao2_cleanup);
char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];
if (ast_sip_push_task_synchronous(NULL, permanent_contact_validate, contact_uri)) {
@@ -376,14 +377,12 @@
return -1;
}
- if (!ast_res_pjsip_find_or_create_contact_status(contact)) {
- ao2_ref(contact, -1);
+ if (!(status = ast_res_pjsip_find_or_create_contact_status(contact))) {
return -1;
}
ast_string_field_set(contact, uri, contact_uri);
ao2_link(aor->permanent_contacts, contact);
- ao2_ref(contact, -1);
}
return 0;
--
To view, visit https://gerrit.asterisk.org/548
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7bb127994677bb3d459f87952f8425c9b9967b12
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
More information about the asterisk-code-review
mailing list