diff --git a/mercurial/thirdparty/xdiff/xutils.c b/mercurial/thirdparty/xdiff/xutils.c --- a/mercurial/thirdparty/xdiff/xutils.c +++ b/mercurial/thirdparty/xdiff/xutils.c @@ -303,12 +303,16 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) { XXH32_hash_t h; - char const *ptr = *data; + char const *ptr; if (flags & XDF_WHITESPACE_FLAGS) return xdl_hash_record_with_whitespace(data, top, flags); - for (; ptr < top && *ptr != '\n'; ptr++) { } + ptr = memchr(*data, '\n', top - *data + 1); + if (!ptr) { + ptr = top; + } + h = XDIFF_XXH32(*data, ptr - *data + 1, 0); *data = ptr < top ? ptr + 1: ptr; return h;