From cfcb9579b1ce41ba62b68c9685370822e94330a5 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 30 Nov 2017 12:20:07 +0100 Subject: 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. --- ufo/ufo-resources.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ufo/ufo-resources.c') 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); -- cgit v1.2.3