[gnome-software/gnome-3-30] snap: Reference GsApp from store snap cache inside mutex
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-30] snap: Reference GsApp from store snap cache inside mutex
- Date: Fri, 14 Sep 2018 14:28:54 +0000 (UTC)
commit adeaa59633a81c8e0e0cc36159558773026589ae
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 4c7948fd..8658aaf8 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]