commit b3bc30c4a5e120a0907ffc2a70680efd43d89330
parent 10c688b98dd59359c517ea5d111f74300771abd0
Author: wwp <subscript@free.fr>
Date: Thu, 30 Sep 2021 21:37:26 +0200
Fix CID 1491096, 1491263, 1491328, 1491348: resource leaks.
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/mh.c b/src/mh.c
@@ -809,17 +809,26 @@ static gint mh_scan_tree(Folder *folder)
if (is_file_exist(dir)) { \
g_warning("file '%s' already exists, " \
"can't create folder", dir); \
+ if (rootpath) \
+ g_free(rootpath); \
+ if (path) \
+ g_free(path); \
return -1; \
} \
- if (make_dir_hier(dir) < 0) \
+ if (make_dir_hier(dir) < 0) { \
+ if (rootpath) \
+ g_free(rootpath); \
+ if (path) \
+ g_free(path); \
return -1; \
+ } \
debug_print("Created dir '%s'\n", dir); \
} \
}
static gint mh_create_tree(Folder *folder)
{
- gchar *rootpath, *f, *path;
+ gchar *rootpath, *f, *path = NULL;
cm_return_val_if_fail(folder != NULL, -1);
@@ -1042,6 +1051,7 @@ static gint mh_rename_folder(Folder *folder, FolderItem *item,
real_name = mh_filename_from_utf8(name);
newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, real_name, NULL);
g_free(real_name);
+ g_free(dirname);
if (g_rename(oldpath, newpath) < 0) {
FILE_OP_ERROR(oldpath, "rename");
@@ -1325,6 +1335,7 @@ static gchar *get_unseen_seq_name(void)
get_home_dir(), G_DIR_SEPARATOR_S,
".mh_profile", NULL);
FILE *fp = claws_fopen(profile_path, "r");
+ g_free(profile_path);
if (fp) {
while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "Unseen-Sequence:", strlen("Unseen-Sequence:"))) {