From 0f71783a12989f020d70c541e0767a281b20defd Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 9 Oct 2024 12:41:59 -0300 Subject: [PATCH] portal-impl: Protect against NULL impls find_portal_implementation_by_name() is nullable, so it's important to deal with it properly. Patch originally proposed by @swick. Closes https://github.com/flatpak/xdg-desktop-portal/issues/1455 --- src/portal-impl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/portal-impl.c b/src/portal-impl.c index 6f8c4525c..b934b59cf 100644 --- a/src/portal-impl.c +++ b/src/portal-impl.c @@ -604,6 +604,12 @@ find_portal_implementation_iface (const PortalInterface *iface) impl = find_portal_implementation_by_name (portal); + if (!impl) + { + g_info ("Requested backend %s does not exist. Skipping...", portal); + continue; + } + if (!portal_impl_supports_iface (impl, iface->dbus_name)) { g_info ("Requested backend %s.portal does not support %s. Skipping...", impl->source, iface->dbus_name); @@ -637,7 +643,7 @@ find_default_implementation_iface (const char *interface) impl = find_portal_implementation_by_name (portal); - if (portal_impl_supports_iface (impl, interface)) + if (impl && portal_impl_supports_iface (impl, interface)) return impl; } return NULL;