From 97bf38633bca394e14dbdd2989ccadd0b39080a0 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 27 Jan 2019 23:33:38 +0100 Subject: [PATCH] gfx-source-texture: Release child source if add_active_child fails --- source/gfx-source-texture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/gfx-source-texture.cpp b/source/gfx-source-texture.cpp index 87255b03..3ab8221f 100644 --- a/source/gfx-source-texture.cpp +++ b/source/gfx-source-texture.cpp @@ -57,6 +57,7 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : throw std::invalid_argument("source does not exist"); } if (!obs_source_add_active_child(_parent, source)) { + obs_source_release(source); throw std::runtime_error("parent is contained in child"); } child = std::make_unique(source, true, true); @@ -76,8 +77,8 @@ gfx::source_texture::source_texture(std::shared_ptr child, std::sha if (!obs_source_add_active_child(parent->get(), child->get())) { throw std::runtime_error("parent is contained in child"); } - this->child = child; - this->parent = parent; + this->child = child; + this->parent = parent; this->render_target = std::make_shared(GS_RGBA, GS_ZS_NONE); }