Fix refcounting of sip_pvt in test_sip_rtpqos test and unlink it from the list of...
[asterisk/asterisk.git] / channels / sip / dialplan_functions.c
index 0f43685..af69dac 100644 (file)
@@ -353,7 +353,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
                goto done;
        }
        ast_channel_tech_set(chan, &sip_tech);
-       ast_channel_tech_pvt_set(chan, p);
+       ast_channel_tech_pvt_set(chan, dialog_ref(p, "Give the owner channel a reference to the dialog"));
        p->owner = chan;
 
        varstr = ast_str_create(16);
@@ -397,8 +397,9 @@ done:
        ast_free(varstr);
        ast_free(buffer);
 
-       /* This unref will take care of destroying the channel, RTP instance, and SIP pvt */
+       /* This unlink and unref will take care of destroying the channel, RTP instance, and SIP pvt */
        if (p) {
+               dialog_unlink_all(p);
                dialog_unref(p, "Destroy test object");
        }
        ast_rtp_engine_unregister(&test_engine);