#36 editing_open: close fd after we've established its validity
Merged 7 months ago by jhrozek. Opened 8 months ago by jhrozek.
jhrozek/libuser neg_fd_close  into  master

file modified
+1 -1

@@ -387,9 +387,9 @@ 

  	backup_name = g_strconcat(e->filename, "-", NULL);

  	fd = open_and_copy_file(e->filename, backup_name, FALSE, error);

  	g_free (backup_name);

- 	close(fd);

  	if (fd == -1)

  		goto err_fscreate;

+ 	close(fd);

  

  	e->new_filename = g_strconcat(e->filename, "+", NULL);

  	e->new_fd = open_and_copy_file(e->filename, e->new_filename, TRUE,

Merges:
https://pagure.io/libuser/issue/26

The code used to first close(fd) and only then check if it's != -1.
Reverse the logic so that the fd is only closed if valid.

rebased onto e553684

7 months ago

Commit 82446dd fixes this pull-request

Pull-Request has been merged by jhrozek

7 months ago

Pull-Request has been merged by jhrozek

7 months ago
Metadata