]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_mwi: Remove inappropriate topic unreference.
authorCorey Farrell <git@cfware.com>
Thu, 19 Sep 2019 16:06:07 +0000 (12:06 -0400)
committerCorey Farrell <git@cfware.com>
Thu, 19 Sep 2019 20:30:58 +0000 (15:30 -0500)
ast_mwi_topic() returns a borrowed reference which should not be
unreferenced, doing so leads to a FRACK.  This was hidden by the fact
that stasis_cache.c leaked the result of cache_remove in
caching_topic_exec.

Change-Id: I51101bf7d07b8dc8ce8fc46b6cb31fbbd213fbc7

main/stasis_cache.c
res/res_pjsip_mwi.c

index 6be4bf1916feab8d2d63c64ec23f2347b46e498e..bcd7e7d1ff73dce9cf55cf6145a3fcfc9380bd69 100644 (file)
@@ -868,7 +868,7 @@ static void caching_topic_exec(void *data, struct stasis_subscription *sub,
                        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);
index 241454605d0fff145351cb510ffe43cf76303c83..82f6e46621d67c4debb04e62bb50e803693b82b0 100644 (file)
@@ -266,7 +266,6 @@ static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char
                mailbox, mwi_sub->id, stasis_topic_name(topic), topic, (int)ao2_ref(topic, 0));
        ao2_ref(mwi_sub, +1);
        mwi_stasis_sub->stasis_sub = stasis_subscribe_pool(topic, mwi_stasis_cb, mwi_sub);
-       ao2_ref(topic, -1);
 
        if (!mwi_stasis_sub->stasis_sub) {
                /* Failed to subscribe. */