res_pjsip_exten_state: Check for vector append failure.
authorCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:48:06 +0000 (18:48 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 23:48:06 +0000 (18:48 -0500)
Release reference to publisher if we fail to add it to the vector.

Change-Id: I64dff3f481b67b9884f37cadba7a5ccf23d084f3

res/res_pjsip_exten_state.c

index 95a4082..3e75613 100644 (file)
@@ -729,8 +729,11 @@ static int exten_state_publisher_state_cb(const char *context, const char *exten
                }
 
                ao2_ref(publisher, +1);
-               AST_VECTOR_APPEND(&pub_data->pubs, publisher);
-               ast_debug(5, "'%s' will publish exten state\n", publisher->name);
+               if (AST_VECTOR_APPEND(&pub_data->pubs, publisher)) {
+                       ao2_ref(publisher, -1);
+               } else {
+                       ast_debug(5, "'%s' will publish exten state\n", publisher->name);
+               }
        }
        ao2_iterator_destroy(&publisher_iter);