]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_outbound_publish: Potential crash due to off nominal path 06/2806/1
authorKevin Harwell <kharwell@digium.com>
Tue, 3 May 2016 20:31:19 +0000 (15:31 -0500)
committerKevin Harwell <kharwell@digium.com>
Wed, 11 May 2016 16:41:39 +0000 (11:41 -0500)
It was possible for the explicit publish destroy function to be called without
the pjsip client ever being initialized. This fix checks to make sure there is
a client to destroy before attempting.

Change-Id: I8eea1bfa3bd472149bfc255310be2a6248688f5c

res/res_pjsip_outbound_publish.c

index 60f9bbb177497d694a50dd0fa074ec781df992c8..bf933cb321d43f5578b53905eaef769c3f813b20 100644 (file)
@@ -687,8 +687,15 @@ static int explicit_publish_destroy(void *data)
 {
        struct ast_sip_outbound_publish_client *client = data;
 
-       pjsip_publishc_destroy(client->client);
-       ao2_ref(client, -1);
+       /*
+        * If there is no pjsip publishing client then we obviously don't need
+        * to destroy it. Also, the ref for the Asterisk publishing client that
+        * pjsip had would not exist or should already be gone as well.
+        */
+       if (client->client) {
+               pjsip_publishc_destroy(client->client);
+               ao2_ref(client, -1);
+       }
 
        return 0;
 }