From: Junio C Hamano <junkio@cox.net>
Date: Tue, 2 Jan 2007 19:22:08 +0000 (-0800)
Subject: fetch-pack: do not use lockfile structure on stack.
X-Git-Tag: v1.5.0-rc1~110
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54b9e0225ad150b4528d7a12f2196ad46f058302;p=git

fetch-pack: do not use lockfile structure on stack.

They are used in atexit() for clean-up, and you will be
accessing unallocated memory at that point.

See 31f584c2 for the fix for a similar problem.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

diff --git a/fetch-pack.c b/fetch-pack.c
index c527bf9e96..1530a94794 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -625,6 +625,8 @@ static int remove_duplicates(int nr_heads, char **heads)
 	return dst;
 }
 
+static struct lock_file lock;
+
 int main(int argc, char **argv)
 {
 	int i, ret, nr_heads;
@@ -632,7 +634,6 @@ int main(int argc, char **argv)
 	int fd[2];
 	pid_t pid;
 	struct stat st;
-	struct lock_file lock;
 
 	setup_git_directory();