diff --git a/main/stasis.c b/main/stasis.c index 4a5d8ac7c0f28f08df06003c1cccaf3430226bcc..186d88fddecf53c5034cb9ae1295702153fa2b89 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -1240,10 +1240,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) */