[gnome-software: 28/29] gs-flatpak: Fix a minor race condition
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 28/29] gs-flatpak: Fix a minor race condition
- Date: Mon, 6 Dec 2021 10:24:18 +0000 (UTC)
commit 45a64859c85455ace3970a882261908c8a65ec2f
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Dec 3 14:01:21 2021 +0000
gs-flatpak: Fix a minor race condition
It’s possible for the `installed_refs` array to be cleared, and its
elements freed, once the mutex is unlocked. That would leave a brief
window in which `xref` points to a just-freed object.
Fix that by grabbing a strong ref on `xref` before releasing the mutex.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
plugins/flatpak/gs-flatpak.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 403c212b1..b4844f1d4 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1499,7 +1499,7 @@ gs_flatpak_ref_to_app (GsFlatpak *self, const gchar *ref,
}
for (guint i = 0; i < self->installed_refs->len; i++) {
- FlatpakInstalledRef *xref = g_ptr_array_index (self->installed_refs, i);
+ g_autoptr(FlatpakInstalledRef) xref = g_object_ref (g_ptr_array_index (self->installed_refs,
i));
g_autofree gchar *ref_tmp = flatpak_ref_format_ref (FLATPAK_REF (xref));
if (g_strcmp0 (ref, ref_tmp) == 0) {
g_mutex_unlock (&self->installed_refs_mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]