[Commits] [SCM] claws branch, master, updated. 3.18.0-134-gd6cdfd3ba

wwp at claws-mail.org wwp at claws-mail.org
Thu Sep 16 00:19:33 CEST 2021


The branch, master has been updated
       via  d6cdfd3bafb0cc30bddada4360688ad6e52bbc65 (commit)
       via  b97377a6c3617400b3d01dc691952915c812bf6e (commit)
      from  cfe830d7a49256c19a73ead62a6b15e74385f7ab (commit)

Summary of changes:
 src/common/file-utils.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)


- Log -----------------------------------------------------------------
commit d6cdfd3bafb0cc30bddada4360688ad6e52bbc65
Author: wwp <subscript at free.fr>
Date:   Thu Sep 16 00:18:50 2021 +0200

    Fix CID 1491202, 1491126, 1491156 and 1491142: resource leaks. And
    simplify the copy algorithm a bit (mostly around error checking).

diff --git a/src/common/file-utils.c b/src/common/file-utils.c
index d0665a097..52fa80b60 100644
--- a/src/common/file-utils.c
+++ b/src/common/file-utils.c
@@ -742,9 +742,9 @@ gint copy_dir(const gchar *src, const gchar *dst)
 			r = copy_file(old_file, new_file, TRUE);
 		}
 #ifndef G_OS_WIN32
-		 /* Windows has no symlinks.  Or well, Vista seems to
-		 have something like this but the semantics might be
-		 different. Thus we don't use it under Windows. */
+		/* Windows has no symlinks.  Or well, Vista seems to
+		   have something like this but the semantics might be
+		   different. Thus we don't use it under Windows. */
 		else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
 			GError *error = NULL;
 			gchar *target = g_file_read_link(old_file, &error);

commit b97377a6c3617400b3d01dc691952915c812bf6e
Author: wwp <subscript at free.fr>
Date:   Thu Sep 16 00:16:19 2021 +0200

    Fix CID 1491202, 1491126, 1491156 and 1491142: resource leaks. And
    simplify the copy algorithm a bit (mostly around error checking).

diff --git a/src/common/file-utils.c b/src/common/file-utils.c
index 30c8c8fc9..d0665a097 100644
--- a/src/common/file-utils.c
+++ b/src/common/file-utils.c
@@ -727,44 +727,45 @@ gint copy_dir(const gchar *src, const gchar *dst)
 		return -1;
 	}
 
-	if (make_dir(dst) < 0)
+	if (make_dir(dst) < 0) {
+		g_dir_close(dir);
 		return -1;
+	}
 
 	while ((name = g_dir_read_name(dir)) != NULL) {
 		gchar *old_file, *new_file;
+		gint r = 0;
 		old_file = g_strconcat(src, G_DIR_SEPARATOR_S, name, NULL);
 		new_file = g_strconcat(dst, G_DIR_SEPARATOR_S, name, NULL);
 		debug_print("copying: %s -> %s\n", old_file, new_file);
 		if (g_file_test(old_file, G_FILE_TEST_IS_REGULAR)) {
-			gint r = copy_file(old_file, new_file, TRUE);
-			if (r < 0) {
-				g_dir_close(dir);
-				return r;
-			}
-                }
+			r = copy_file(old_file, new_file, TRUE);
+		}
 #ifndef G_OS_WIN32
-                /* Windows has no symlinks.  Or well, Vista seems to
-                   have something like this but the semantics might be
-                   different.  Thus we don't use it under Windows. */
-		 else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
+		 /* Windows has no symlinks.  Or well, Vista seems to
+		 have something like this but the semantics might be
+		 different. Thus we don't use it under Windows. */
+		else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
 			GError *error = NULL;
-			gint r = 0;
 			gchar *target = g_file_read_link(old_file, &error);
-			if (target)
+			if (error) {
+				g_warning("couldn't read link: %s", error->message);
+				g_error_free(error);
+			}
+			if (target) {
 				r = symlink(target, new_file);
-			g_free(target);
-			if (r < 0) {
-				g_dir_close(dir);
-				return r;
+				g_free(target);
 			}
-                 }
+		}
 #endif /*G_OS_WIN32*/
-	        else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
-			gint r = copy_dir(old_file, new_file);
-			if (r < 0) {
-				g_dir_close(dir);
-				return r;
-			}
+		else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
+			r = copy_dir(old_file, new_file);
+		}
+		g_free(old_file);
+		g_free(new_file);
+		if (r < 0) {
+			g_dir_close(dir);
+			return r;
 		}
 	}
 	g_dir_close(dir);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list