# [PATCH] Fix handle leak in sha1_file/unpack_objects if there were damaged object data

2 messages from 2008-11-19 to 2008-11-19. Participants: Alex Riesen, Nicolas Pitre.
Thread: https://gitlist.dev/t/16390

## Alex Riesen, 2008-11-19 11:14

Subject: [PATCH] Fix handle leak in sha1_file/unpack_objects if there were damaged object data
Message-ID: <81b0412b0811190314k92a0acbn3ea820cce2a7a40b@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0811190314k92a0acbn3ea820cce2a7a40b%40mail.gmail.com

```
In the case of bad packed object CRC, unuse_pack wasn't called after
check_pack_crc which calls use_pack.

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


From 3b4c13ddeebe4bc54a3f9ab9bd26909cc5e1eff3 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Wed, 19 Nov 2008 11:17:13 +0100
Subject: [PATCH] Fix handle leak in sha1_file/unpack_objects if there were damaged object data

In the case of bad packed object CRC, unuse_pack wasn't called after
check_pack_crc which calls use_pack.

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

diff --git a/sha1_file.c b/sha1_file.c
index 75a748a..0106e2c 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1749,6 +1749,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
 			error("bad packed object CRC for %s",
 			      sha1_to_hex(sha1));
 			mark_bad_packed_object(p, sha1);
+			unuse_pack(&w_curs);
 			return NULL;
 		}
 	}
-- 
1.6.0.4.644.gb619a


```

## Nicolas Pitre, 2008-11-19 12:49

Subject: Re: [PATCH] Fix handle leak in sha1_file/unpack_objects if there were damaged object data
Message-ID: <alpine.LFD.2.00.0811190749250.27509@xanadu.home>
URL: https://gitlist.dev/e/alpine.LFD.2.00.0811190749250.27509%40xanadu.home
In-Reply-To: <81b0412b0811190314k92a0acbn3ea820cce2a7a40b@mail.gmail.com>

```
On Wed, 19 Nov 2008, Alex Riesen wrote:

> In the case of bad packed object CRC, unuse_pack wasn't called after
> check_pack_crc which calls use_pack.
> 
> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

Acked-by: Nicolas Pitre <nico@cam.org>


> ---
>  sha1_file.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 


Nicolas

```
