[gnome-software: 4/5] repos: Fix a minor memory leak when parsing key files




commit e40d97577a34433fa812dc86fd3ff73953d255ad
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Dec 15 16:16:01 2021 +0000

    repos: Fix a minor memory leak when parsing key files
    
    Spotted while working on the code unrelatedly.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/repos/gs-plugin-repos.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/plugins/repos/gs-plugin-repos.c b/plugins/repos/gs-plugin-repos.c
index e119eb8ea..8e57e8ba5 100644
--- a/plugins/repos/gs-plugin-repos.c
+++ b/plugins/repos/gs-plugin-repos.c
@@ -139,25 +139,25 @@ gs_plugin_repos_load (GsPluginRepos  *self,
                /* we can have multiple repos in one file */
                groups = g_key_file_get_groups (kf, NULL);
                for (i = 0; groups[i] != NULL; i++) {
-                       g_autofree gchar *tmp = NULL;
+                       g_autofree gchar *baseurl = NULL, *metalink = NULL;
 
                        g_hash_table_insert (new_filenames,
                                             g_strdup (groups[i]),
                                             g_strdup (filename));
 
-                       tmp = g_key_file_get_string (kf, groups[i], "baseurl", NULL);
-                       if (tmp != NULL) {
+                       baseurl = g_key_file_get_string (kf, groups[i], "baseurl", NULL);
+                       if (baseurl != NULL) {
                                g_hash_table_insert (new_urls,
                                                     g_strdup (groups[i]),
-                                                    g_strdup (tmp));
+                                                    g_steal_pointer (&baseurl));
                                continue;
                        }
 
-                       tmp = g_key_file_get_string (kf, groups[i], "metalink", NULL);
-                       if (tmp != NULL) {
+                       metalink = g_key_file_get_string (kf, groups[i], "metalink", NULL);
+                       if (metalink != NULL) {
                                g_hash_table_insert (new_urls,
                                                     g_strdup (groups[i]),
-                                                    g_strdup (tmp));
+                                                    g_steal_pointer (&metalink));
                                continue;
                        }
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]