commit 91bc6b055d73cba877dd0eb0632792c6ac4cefa1
parent fa42bca6ef8540e676b56e18f541eded201869a7
Author: Michael Rasmussen <mir@datanom.net>
Date: Mon, 11 Jun 2018 22:46:32 +0200
Fix a possible memory leak
Signed-off-by: Michael Rasmussen <mir@datanom.net>
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/plugins/archive/libarchive_archive.c b/src/plugins/archive/libarchive_archive.c
@@ -589,7 +589,6 @@ const gchar* archive_create(const char* archive_name, GSList* files,
set_progress_file_label(msg);
g_free(msg);
#endif
- entry = archive_entry_new();
if ((fd = g_open(filename, O_RDONLY, 0)) == -1) {
FILE_OP_ERROR(filename, "g_open");
}
@@ -597,6 +596,7 @@ const gchar* archive_create(const char* archive_name, GSList* files,
if (g_stat(filename, &st) == -1) {
FILE_OP_ERROR(filename, "g_stat");
} else {
+ entry = archive_entry_new();
archive_entry_copy_stat(entry, &st);
archive_entry_set_pathname(entry, filename);
if (S_ISLNK(st.st_mode)) {
@@ -625,10 +625,10 @@ const gchar* archive_create(const char* archive_name, GSList* files,
g_free(buf);
}
}
+ archive_entry_free(entry);
}
if (!g_close(fd, &err) || err)
FILE_OP_ERROR(filename, "g_close");
- archive_entry_free(entry);
}
}
g_free(filename);