[gnome-panel] menu: redo get_file_root
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] menu: redo get_file_root
- Date: Sat, 20 Mar 2021 22:29:14 +0000 (UTC)
commit 4e45b2ad295053ef5f3fe175fb5592ad03a211c3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Mar 21 00:19:03 2021 +0200
menu: redo get_file_root
Coverity thinks that we are freeing file. Redo function to avoid
multiple false positive defects.
Coverity CID: #1502699, #1502700, #1502703, #1502705
modules/menu/gp-menu-utils.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/modules/menu/gp-menu-utils.c b/modules/menu/gp-menu-utils.c
index 5477e419a..273db690b 100644
--- a/modules/menu/gp-menu-utils.c
+++ b/modules/menu/gp-menu-utils.c
@@ -78,15 +78,20 @@ static GFile *
get_file_root (GFile *file)
{
GFile *parent;
+ GFile *root;
+
+ parent = g_file_get_parent (file);
+ if (parent == NULL)
+ return g_object_ref (file);
- g_object_ref (file);
- while ((parent = g_file_get_parent (file)) != NULL)
+ root = parent;
+ while ((parent = g_file_get_parent (root)) != NULL)
{
- g_object_unref (file);
- file = parent;
+ g_object_unref (root);
+ root = parent;
}
- return file;
+ return root;
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]