diff --git a/builtin-update-index.c b/builtin-update-index.c
index 325cd0944dd81e1531dd097da3069c46a5321523..1a4200d151dd8e876c6f84531422cae50b049aa3 100644 (file)
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
git_config(git_default_config);
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
- lock_file = xmalloc(sizeof(struct lock_file));
+ lock_file = xcalloc(1, sizeof(struct lock_file));
newfd = hold_lock_file_for_update(lock_file, get_index_file());
if (newfd < 0)
finish:
if (active_cache_changed) {
if (write_cache(newfd, active_cache, active_nr) ||
- commit_lock_file(lock_file))
+ close(newfd) || commit_lock_file(lock_file))
die("Unable to write new index file");
}