aboutsummaryrefslogtreecommitdiff
path: root/name-hash.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-04-19 21:37:25 -0700
committerJunio C Hamano <gitster@pobox.com>2017-04-19 21:37:25 -0700
commit8377f34540a33074df10ffcf27c6e90f9c88c847 (patch)
tree490553754534e06e6e2d616d89b01ecd0a1115b0 /name-hash.c
parent5feb8b8429b405e72b5786036774c9ffb20b64d9 (diff)
parentc9d4999155700651a37f4eb577cec1f4b5b8d6be (diff)
downloadgit-8377f34540a33074df10ffcf27c6e90f9c88c847.tar.gz
git-8377f34540a33074df10ffcf27c6e90f9c88c847.tar.xz
Merge branch 'jh/memihash-opt'
Hotfix for a topic that is already in 'master'. * jh/memihash-opt: p0004: make perf test executable t3008: skip lazy-init test on a single-core box test-online-cpus: helper to return cpu count name-hash: fix buffer overrun
Diffstat (limited to 'name-hash.c')
-rw-r--r--name-hash.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/name-hash.c b/name-hash.c
index cac313c78..39309efb7 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -342,7 +342,9 @@ static int handle_range_dir(
* Scan forward in the index array for index entries having the same
* path prefix (that are also in this directory).
*/
- if (strncmp(istate->cache[k_start + 1]->name, prefix->buf, prefix->len) > 0)
+ if (k_start + 1 >= k_end)
+ k = k_end;
+ else if (strncmp(istate->cache[k_start + 1]->name, prefix->buf, prefix->len) > 0)
k = k_start + 1;
else if (strncmp(istate->cache[k_end - 1]->name, prefix->buf, prefix->len) == 0)
k = k_end;