summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2016-05-22 22:08:13 +0200
committerSylvain Munaut <tnt@246tNt.com>2016-05-22 22:34:22 +0200
commitdbe239380fe1455a314ca75232969a6adb442eef (patch)
tree1407649686db8080ae2812e55118996a2d12e61a
parent249434d0206e4f796da914b040ed508402aa2e10 (diff)
gr-fosphor: Improve cleanup path of the worker thread in case of init fail
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--lib/base_sink_c_impl.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/base_sink_c_impl.cc b/lib/base_sink_c_impl.cc
index bfb672c..725f633 100644
--- a/lib/base_sink_c_impl.cc
+++ b/lib/base_sink_c_impl.cc
@@ -82,6 +82,9 @@ base_sink_c_impl::~base_sink_c_impl()
void base_sink_c_impl::worker()
{
+ /* Zero-init */
+ this->d_fosphor = NULL;
+
/* Init GL context */
this->glctx_init();
@@ -92,8 +95,10 @@ void base_sink_c_impl::worker()
gr::thread::scoped_lock guard(s_boot_mutex);
this->d_fosphor = fosphor_init();
- if (!this->d_fosphor)
- return;
+ if (!this->d_fosphor) {
+ GR_LOG_ERROR(d_logger, "Failed to initialize fosphor");
+ goto error;
+ }
}
this->settings_apply(~SETTING_DIMENSIONS);
@@ -105,8 +110,10 @@ void base_sink_c_impl::worker()
this->glctx_poll();
}
+error:
/* Cleanup fosphor */
- fosphor_release(this->d_fosphor);
+ if (this->d_fosphor)
+ fosphor_release(this->d_fosphor);
/* And GL context */
this->glctx_fini();