# [PATCH] Fix handle leak in "git branch -D"

1 messages from 2007-08-10 to 2007-08-10. Participants: Alex Riesen.
Thread: https://gitlist.dev/t/9471

## Alex Riesen, 2007-08-10 13:06

Subject: [PATCH] Fix handle leak in "git branch -D"
Message-ID: <81b0412b0708100606v7bcceaf6xc0783ea9761d7ba4@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0708100606v7bcceaf6xc0783ea9761d7ba4%40mail.gmail.com

```
On Windows (it can't touch open files in any way) the following fails:

    git branch -D branch1 branch2

if the both branches are in packed-refs.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 refs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

BTW, why does not commit_lock_file takes care of closing the file
opened by hold_lock_file_for_update?


From 4e219bf5b2c7de091973336f6143f77fe9a96efc Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Fri, 10 Aug 2007 15:06:22 +0200
Subject: [PATCH] Fix handle leak in "git branch -D"

On Windows (it can't touch open files in any way) the following fails:

    git branch -D branch1 branch2

if the both branches are in packed-refs.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 refs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/refs.c b/refs.c
index fac6548..09a2c87 100644
--- a/refs.c
+++ b/refs.c
@@ -869,6 +869,7 @@ static int repack_without_ref(const char *refname)
 			die("too long a refname '%s'", list->name);
 		write_or_die(fd, line, len);
 	}
+	close(fd);
 	return commit_lock_file(&packlock);
 }
 
-- 
1.5.3.rc4.81.gbd62


```
