[gnome-software] snap: Reference GsApp from store snap cache inside mutex
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] snap: Reference GsApp from store snap cache inside mutex
- Date: Wed, 5 Sep 2018 05:01:09 +0000 (UTC)
commit d4442c959a776075e81b2c01054ff867ae16b2fe
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Aug 29 21:08:58 2018 +1200
snap: Reference GsApp from store snap cache inside mutex
Previously the reference was done outside the mutex and there is a chance
another thread could close the last reference before we get the next one.
plugins/snap/gs-plugin-snap.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index 49162d03..d34948fe 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -224,7 +224,13 @@ store_snap_cache_lookup (GsPlugin *plugin, const gchar *name)
{
GsPluginData *priv = gs_plugin_get_data (plugin);
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->store_snaps_lock);
- return g_hash_table_lookup (priv->store_snaps, name);
+ SnapdSnap *snap;
+
+ snap = g_hash_table_lookup (priv->store_snaps, name);
+ if (snap == NULL)
+ return NULL;
+
+ return g_object_ref (snap);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]