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

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