# [PATCH] Fix off-by-one in read_tree_recursive

5 messages from 2009-04-20 to 2009-04-21. Participants: Johannes Schindelin, Andy Lester, Junio C Hamano.
Thread: https://gitlist.dev/t/18971

## Johannes Schindelin, 2009-04-20 17:44

Subject: [PATCH] Fix off-by-one in read_tree_recursive
Message-ID: <f62793069ecb99138c435edf37533906c4aae301.1240249482u.git.johannes.schindelin@gmx.de>
URL: https://gitlist.dev/e/f62793069ecb99138c435edf37533906c4aae301.1240249482u.git.johannes.schindelin%40gmx.de
In-Reply-To: <cover.1240249482u.git.johannes.schindelin@gmx.de>

```
Found by valgrind.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 tree.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tree.c b/tree.c
index 0d703a0..5ab90af 100644
--- a/tree.c
+++ b/tree.c
@@ -62,6 +62,7 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
 				continue;
 			/* pathspecs match only at the directory boundaries */
 			if (!matchlen ||
+			    baselen == matchlen ||
 			    base[matchlen] == '/' ||
 			    match[matchlen - 1] == '/')
 				return 1;
-- 
1.6.2.1.493.g67cf3

```

## Andy Lester, 2009-04-20 18:06

Subject: valgrind
Message-ID: <872ACD6C-B99B-4BE4-BD7C-3A7B3255B3E1@petdance.com>
URL: https://gitlist.dev/e/872ACD6C-B99B-4BE4-BD7C-3A7B3255B3E1%40petdance.com
In-Reply-To: <f62793069ecb99138c435edf37533906c4aae301.1240249482u.git.johannes.schindelin@gmx.de>

```

On Apr 20, 2009, at 12:44 PM, Johannes Schindelin wrote:

> Found by valgrind.


How are you running valgrind?  Do you have a test suite for it?  A  
make target?

xoa


--
Andy Lester => andy@petdance.com => www.theworkinggeek.com => AIM:petdance

```

## Johannes Schindelin, 2009-04-20 18:34

Subject: Re: valgrind
Message-ID: <alpine.DEB.1.00.0904202033220.6771@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0904202033220.6771%40intel-tinevez-2-302
In-Reply-To: <872ACD6C-B99B-4BE4-BD7C-3A7B3255B3E1@petdance.com>

```
Hi,

On Mon, 20 Apr 2009, Andy Lester wrote:

> On Apr 20, 2009, at 12:44 PM, Johannes Schindelin wrote:
> 
> >Found by valgrind.
> 
> How are you running valgrind?  Do you have a test suite for it?  A make 
> target?

Yes, it was merged into Git:

http://repo.or.cz/w/alt-git.git?a=commitdiff;h=8a61097cde387870921e822bdf90b4ffd3792845

Hth,
Dscho

```

## Andy Lester, 2009-04-20 18:36

Subject: Re: valgrind
Message-ID: <FCFFBD39-6C9E-4D7E-B28F-4AF0E5B9E5EB@petdance.com>
URL: https://gitlist.dev/e/FCFFBD39-6C9E-4D7E-B28F-4AF0E5B9E5EB%40petdance.com
In-Reply-To: <alpine.DEB.1.00.0904202033220.6771@intel-tinevez-2-302>

```

On Apr 20, 2009, at 1:34 PM, Johannes Schindelin wrote:

> Yes, it was merged into Git:
>
> http://repo.or.cz/w/alt-git.git?a=commitdiff;h=8a61097cde387870921e822bdf90b4ffd3792845


Very cool.  In my Copious Free Time, I'm trying to get a splint target  
built up.

xoxo,
Andy

--
Andy Lester => andy@petdance.com => www.theworkinggeek.com => AIM:petdance

```

## Junio C Hamano, 2009-04-21 05:33

Subject: Re: [PATCH] Fix off-by-one in read_tree_recursive
Message-ID: <7vk55ebmfl.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk55ebmfl.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <f62793069ecb99138c435edf37533906c4aae301.1240249482u.git.johannes.schindelin@gmx.de>

```
Thanks.
.

```
