[Asterisk-code-review] stasis: Fix leaks (...asterisk[17])
Corey Farrell
asteriskteam at digium.com
Thu Sep 19 17:36:23 CDT 2019
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/12906
Change subject: stasis: Fix leaks
......................................................................
stasis: Fix leaks
* Release reference returned by cache_remove
* state_alloc unconditionally bumped state_topic even when it was
locally allocated.
Change-Id: I51101bf7d07b8dc8ce8fc46b6cb31fbbd213fbc7
---
M main/stasis_cache.c
M main/stasis_state.c
2 files changed, 8 insertions(+), 8 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/06/12906/1
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index 6be4bf1..bcd7e7d 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -868,7 +868,7 @@
ao2_wrlock(caching_topic->cache->entries);
sub = cache_find(caching_topic->cache->entries, stasis_subscription_change_type(), change->uniqueid);
if (sub) {
- cache_remove(caching_topic->cache->entries, sub, stasis_message_eid(message));
+ ao2_cleanup(cache_remove(caching_topic->cache->entries, sub, stasis_message_eid(message)));
ao2_cleanup(sub);
}
ao2_unlock(caching_topic->cache->entries);
diff --git a/main/stasis_state.c b/main/stasis_state.c
index a915972..aa00f9a 100644
--- a/main/stasis_state.c
+++ b/main/stasis_state.c
@@ -165,6 +165,13 @@
return NULL;
}
ast_free(name);
+ } else {
+ /*
+ * Since the state topic was passed in, go ahead and bump its reference.
+ * By doing this here first, it allows us to consistently decrease the reference on
+ * state allocation error.
+ */
+ ao2_ref(state_topic, +1);
}
if (!id) {
@@ -175,13 +182,6 @@
id = state_id_by_topic(manager->all_topic, state_topic);
}
- /*
- * Since the state topic could have been passed in, go ahead and bump its reference.
- * By doing this here first, it allows us to consistently decrease the reference on
- * state allocation error.
- */
- ao2_ref(state_topic, +1);
-
state = ao2_alloc(sizeof(*state) + strlen(id) + 1, state_dtor);
if (!state) {
ast_log(LOG_ERROR, "Unable to allocate state '%s' in manager '%s'\n",
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/12906
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: I51101bf7d07b8dc8ce8fc46b6cb31fbbd213fbc7
Gerrit-Change-Number: 12906
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190919/1964280d/attachment.html>
More information about the asterisk-code-review
mailing list