From 596d22a4492d6712329cb4882a22859bdaef2c96 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Thu, 3 Sep 2020 09:06:37 +0200 Subject: [PATCH] context: Fix invalid accesses to GUsbContext if USB is missing When USB cannot be initialised (inside the flatpak build environment), then we would have invalid accesses to the NULL pointer. Fix those. --- libfprint/fp-context.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c index e70077f..6971763 100644 --- a/libfprint/fp-context.c +++ b/libfprint/fp-context.c @@ -210,7 +210,8 @@ fp_context_finalize (GObject *object) g_clear_object (&priv->cancellable); g_clear_pointer (&priv->drivers, g_array_unref); - g_object_run_dispose (G_OBJECT (priv->usb_ctx)); + if (priv->usb_ctx) + g_object_run_dispose (G_OBJECT (priv->usb_ctx)); g_clear_object (&priv->usb_ctx); G_OBJECT_CLASS (fp_context_parent_class)->finalize (object); @@ -342,7 +343,8 @@ fp_context_enumerate (FpContext *context) priv->enumerated = TRUE; /* USB devices are handled from callbacks */ - g_usb_context_enumerate (priv->usb_ctx); + if (priv->usb_ctx) + g_usb_context_enumerate (priv->usb_ctx); /* Handle Virtual devices based on environment variables */ for (i = 0; i < priv->drivers->len; i++)