OSDN Git Service

config.c: fix writing config files on Windows network shares
authorKarsten Blees <karsten.blees@gmail.com>
Tue, 30 Jun 2015 14:34:13 +0000 (16:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2015 18:01:59 +0000 (11:01 -0700)
Renaming to an existing file doesn't work on Windows network shares if the
target file is open.

munmap() the old config file before commit_lock_file.

Signed-off-by: Karsten Blees <blees@dcon.de>
Acked-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c

index 27a73c8..69824eb 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2116,6 +2116,9 @@ int git_config_set_multivar_in_file(const char *config_filename,
                                          contents_sz - copy_begin) <
                            contents_sz - copy_begin)
                                goto write_err_out;
+
+               munmap(contents, contents_sz);
+               contents = NULL;
        }
 
        if (commit_lock_file(lock) < 0) {