summaryrefslogtreecommitdiff
path: root/ufo/ufo-resources.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-11-30 12:20:07 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-11-30 12:21:30 +0100
commitcfcb9579b1ce41ba62b68c9685370822e94330a5 (patch)
tree4ad7eeb4b0981681436d8116aec83391184f7118 /ufo/ufo-resources.c
parentbee844f2189744b12a060ff0cb8718142f36f1f0 (diff)
Fix rare segfault
In rare circumstances we can enumerate OpenCL devices but not create a context with them. When unwinding the resource objects we have to make sure not to free device names which were never allocated for.
Diffstat (limited to 'ufo/ufo-resources.c')
-rw-r--r--ufo/ufo-resources.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ufo/ufo-resources.c b/ufo/ufo-resources.c
index 37885ca..b099d71 100644
--- a/ufo/ufo-resources.c
+++ b/ufo/ufo-resources.c
@@ -1151,8 +1151,10 @@ ufo_resources_finalize (GObject *object)
g_hash_table_destroy (priv->programs);
- for (guint i = 0; i < priv->n_devices; i++)
- g_free (priv->device_names[i]);
+ if (priv->device_names != NULL) {
+ for (guint i = 0; i < priv->n_devices; i++)
+ g_free (priv->device_names[i]);
+ }
if (priv->context) {
g_debug ("FREE context=%p", (gpointer) priv->context);