diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-04-19 21:37:25 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-04-19 21:37:25 -0700 |
commit | 8377f34540a33074df10ffcf27c6e90f9c88c847 (patch) | |
tree | 490553754534e06e6e2d616d89b01ecd0a1115b0 /name-hash.c | |
parent | Merge branch 'vn/revision-shorthand-for-side-branch-log' (diff) | |
parent | p0004: make perf test executable (diff) | |
download | tgif-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/name-hash.c b/name-hash.c index cac313c78d..39309efb7f 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; |