stasis: Release object if vector append fails.
authorCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 21:33:00 +0000 (16:33 -0500)
committerCorey Farrell <git@cfware.com>
Mon, 6 Nov 2017 21:33:00 +0000 (16:33 -0500)
Change-Id: I3e5cc669169aab6175ddfaf7486edeaeb4fdcfb1

main/stasis.c

index a82e938..4328b84 100644 (file)
@@ -1239,10 +1239,9 @@ struct ast_multi_object_blob *ast_multi_object_blob_create(struct ast_json *blob
 void ast_multi_object_blob_add(struct ast_multi_object_blob *multi,
        enum stasis_user_multi_object_snapshot_type type, void *object)
 {
-       if (!multi || !object) {
-               return;
+       if (!multi || !object || AST_VECTOR_APPEND(&multi->snapshots[type], object)) {
+               ao2_cleanup(object);
        }
-       AST_VECTOR_APPEND(&multi->snapshots[type],object);
 }
 
 /*! \brief Publish single channel user event (for app_userevent compatibility) */