Blob Blame History Raw
From 72cad276323914503c3271aa0670d309c1124125 Mon Sep 17 00:00:00 2001
From: Matthew Leeds <matthew.leeds@endlessm.com>
Date: Tue, 1 May 2018 09:18:03 -0700
Subject: [PATCH] lib: Don't try to use a NULL FlatpakRemoteState

In flatpak_remote_ref_new(), the state parameter is optional, so check
if it's NULL before trying to use it in
flatpak_remote_state_lookup_sparse_cache(). This prevents a seg fault
when GNOME Software is installing a .flatpakref file.

Fixes https://github.com/flatpak/flatpak/issues/1632

Closes: #1635
Approved by: pwithnall
---
 lib/flatpak-remote-ref.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/flatpak-remote-ref.c b/lib/flatpak-remote-ref.c
index 0a4c1e4d..3573fa6d 100644
--- a/lib/flatpak-remote-ref.c
+++ b/lib/flatpak-remote-ref.c
@@ -350,7 +350,9 @@ flatpak_remote_ref_new (FlatpakCollectionRef *coll_ref,
   if (metadata)
     metadata_bytes = g_bytes_new (metadata, strlen (metadata));
 
-  sparse = flatpak_remote_state_lookup_sparse_cache (state, full_ref, NULL);
+  if (state)
+    sparse = flatpak_remote_state_lookup_sparse_cache (state, full_ref, NULL);
+
   if (sparse)
     {
       g_variant_lookup (sparse, "eol", "&s", &eol);
-- 
2.17.0