Blame SOURCES/0007-editing_open-close-fd-after-we-ve-established-its-va.patch

020281
From e5536845298b6672a16e5866a823fcf6562c6cf3 Mon Sep 17 00:00:00 2001
020281
From: Jakub Hrozek <jakub.hrozek@posteo.se>
020281
Date: Wed, 26 Sep 2018 21:15:38 +0200
020281
Subject: [PATCH 7/7] editing_open: close fd after we've established its
020281
 validity
020281
020281
Merges:
020281
https://pagure.io/libuser/issue/26
020281
020281
The code used to first close(fd) and only then check if it's != -1.
020281
Reverse the logic so that the fd is only closed if valid.
020281
---
020281
 modules/files.c | 2 +-
020281
 1 file changed, 1 insertion(+), 1 deletion(-)
020281
020281
diff --git a/modules/files.c b/modules/files.c
020281
index 8c2a282b6448bbfb313b5d4f5eeb28b8240bccd5..b8bf8a60e5810c0b705bd91efbdf9e27e851cd2b 100644
020281
--- a/modules/files.c
020281
+++ b/modules/files.c
020281
@@ -387,9 +387,9 @@ editing_open(struct lu_module *module, const char *file_suffix,
020281
 	backup_name = g_strconcat(e->filename, "-", NULL);
020281
 	fd = open_and_copy_file(e->filename, backup_name, FALSE, error);
020281
 	g_free (backup_name);
020281
-	close(fd);
020281
 	if (fd == -1)
020281
 		goto err_fscreate;
020281
+	close(fd);
020281
 
020281
 	e->new_filename = g_strconcat(e->filename, "+", NULL);
020281
 	e->new_fd = open_and_copy_file(e->filename, e->new_filename, TRUE,
020281
-- 
020281
2.14.4
020281