hex: make wraparound of the index into ring-buffer explicit
[gitweb.git] / diff.c
diff --git a/diff.c b/diff.c
index cc8e81290ab67d14b1c0f63ccd6c6b2e6a0e8b0c..7a4309397cb7fd6819d6f643b259c2bc3abe202f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -949,7 +949,8 @@ static int find_word_boundaries(mmfile_t *buffer, regex_t *word_regex,
 {
        if (word_regex && *begin < buffer->size) {
                regmatch_t match[1];
-               if (!regexec(word_regex, buffer->ptr + *begin, 1, match, 0)) {
+               if (!regexec_buf(word_regex, buffer->ptr + *begin,
+                                buffer->size - *begin, 1, match, 0)) {
                        char *p = memchr(buffer->ptr + *begin + match[0].rm_so,
                                        '\n', match[0].rm_eo - match[0].rm_so);
                        *end = p ? p - buffer->ptr : match[0].rm_eo + *begin;