Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
git_config_rename_section_in_file(): avoid resource leak
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:55:41 +0000
(15:55 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 8 May 2017 03:18:19 +0000
(12:18 +0900)
In case of errors, we really want the file descriptor to be closed.
Discovered by a Coverity scan.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(from parent 1:
5748693
)
diff --git
a/config.c
b/config.c
index b4a3205da32faf43db1ab990f08c0bb941af87d0..a30056ec7e9a0cca87dea494a92a4671a19b7643 100644
(file)
--- a/
config.c
+++ b/
config.c
@@
-2621,7
+2621,7
@@
int git_config_rename_section_in_file(const char *config_filename,
struct lock_file *lock;
int out_fd;
char buf[1024];
- FILE *config_file;
+ FILE *config_file
= NULL
;
struct stat st;
if (new_name && !section_name_is_ok(new_name)) {
@@
-2703,11
+2703,14
@@
int git_config_rename_section_in_file(const char *config_filename,
}
}
fclose(config_file);
+ config_file = NULL;
commit_and_out:
if (commit_lock_file(lock) < 0)
ret = error_errno("could not write config file %s",
config_filename);
out:
+ if (config_file)
+ fclose(config_file);
rollback_lock_file(lock);
out_no_rollback:
free(filename_buf);