[PATCH] builtin-checkout: use struct lock_file correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A lock_file instance must not be cleaned up, since an atexit() handler
will try to access even correctly committed lock_files, since it has
to make sure that they were correctly committed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	I am using builtin checkout since quite some time, but this is the 
	first time it crashed... That fix helps; you might want to amend 
	your patch 11/11.

 builtin-checkout.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 0894eae..12000b1 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -67,14 +67,14 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
 static int read_tree_some(struct tree *tree, const char **pathspec)
 {
 	int newfd;
-	struct lock_file lock_file;
-	newfd = hold_locked_index(&lock_file, 1);
+	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+	newfd = hold_locked_index(lock_file, 1);
 	read_cache();
 
 	read_tree_recursive(tree, "", 0, 0, pathspec, update_some);
 
 	if (write_cache(newfd, active_cache, active_nr) ||
-	    commit_locked_index(&lock_file))
+	    commit_locked_index(lock_file))
 		die("unable to write new index file");
 
 	/* update the index with the given tree's info
-- 
1.5.4.1.1353.g0d5dd


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux