Merge branch 'jk/bug-to-abort' into maint
[gitweb.git] / name-hash.c
index cac313c78d3fa7aba7a7ad6ea6cf5f6fd10a6445..39309efb7f9e21eb7a039b6b17cdb0d9f1859820 100644 (file)
@@ -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;