Fix some leaks
authorTomas Mlcoch <tmlcoch@redhat.com>
Tue, 13 Mar 2012 11:15:25 +0000 (12:15 +0100)
committerTomas Mlcoch <tmlcoch@redhat.com>
Tue, 13 Mar 2012 11:15:25 +0000 (12:15 +0100)
createrepo_c.c
repomd.c

index 0f1548f..41e0617 100644 (file)
@@ -999,7 +999,10 @@ int main(int argc, char **argv) {
     gchar *pri_xml_name = g_strconcat("repodata/", "primary.xml.gz", NULL);
     gchar *fil_xml_name = g_strconcat("repodata/", "filelists.xml.gz", NULL);
     gchar *oth_xml_name = g_strconcat("repodata/", "other.xml.gz", NULL);
-    gchar *groupfile_name = g_strconcat("repodata/", get_filename(groupfile), NULL);
+    gchar *groupfile_name = NULL;
+    if (groupfile) {
+        groupfile_name = g_strconcat("repodata/", get_filename(groupfile), NULL);
+    }
 
     struct repomdResult *repomd_res = xml_repomd(out_dir, cmd_options.unique_md_filenames, pri_xml_name, fil_xml_name, oth_xml_name, NULL, NULL, NULL, groupfile_name, &cmd_options.checksum_type);
     gchar *repomd_path = g_strconcat(out_repo, "repomd.xml", NULL);
@@ -1032,6 +1035,7 @@ int main(int argc, char **argv) {
 
     g_free(in_repo);
     g_free(out_repo);
+    g_free(tmp_out_repo);
     g_free(in_dir);
     g_free(out_dir);
     g_free(pri_xml_filename);
index f9ec1da..20053ea 100644 (file)
--- a/repomd.c
+++ b/repomd.c
@@ -259,7 +259,7 @@ int fill_missing_data(const char *base_path, struct repomdData *md, ChecksumType
 void process_groupfile(const char *base_path, struct repomdData *groupfile,
                        struct repomdData *cgroupfile, ChecksumType *checksum_type)
 {
-    if (!groupfile || !(groupfile->location_href) || !strlen(groupfile->location_href)) {
+    if (!groupfile || !(groupfile->location_href) || !strlen(groupfile->location_href) || !cgroupfile) {
         return;
     }
 
@@ -287,6 +287,8 @@ void process_groupfile(const char *base_path, struct repomdData *groupfile,
     if (!g_file_test(path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
         // File doesn't exists
         g_warning(MODULE"process_groupfile: File %s doesn't exists", path);
+        g_free(path);
+        g_free(cpath);
         return;
     }
 
@@ -590,7 +592,7 @@ struct repomdResult *xml_repomd_2(const char *path, int rename_to_unique,
     res->fil_sqlite_location = fil_sqlite ? g_strdup(fil_sqlite->location_href) : NULL;
     res->oth_sqlite_location = oth_sqlite ? g_strdup(oth_sqlite->location_href) : NULL;
     res->groupfile_location = groupfile ? g_strdup(groupfile->location_href) : NULL;
-    res->cgroupfile_location = cgroupfile ? (char *) cgroupfile->location_href : NULL;
+    res->cgroupfile_location = cgroupfile ? g_strdup(cgroupfile->location_href) : NULL;
 
     // Get revision
 
@@ -620,7 +622,7 @@ struct repomdResult *xml_repomd(const char *path, int rename_to_unique, const ch
     struct repomdData *fil_sqlite_rd = NULL;
     struct repomdData *oth_sqlite_rd = NULL;
     struct repomdData *groupfile_rd  = NULL;
-    struct repomdData *cgroupfile_rd  = NULL;
+    struct repomdData *cgroupfile_rd = NULL;
 
     if (pri_xml) {
         pri_xml_rd = new_repomddata();