diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -47,10 +47,10 @@ int bdiff_splitlines(const char *a, ssiz /* build the line array and calculate hashes */ hash = 0; - for (p = a; p < a + len; p++) { + for (p = a; p < plast; p++) { hash = HASH(hash, *p); - if (*p == '\n' || p == plast) { + if (*p == '\n') { l->hash = hash; hash = 0; l->len = p - b + 1; @@ -61,6 +61,15 @@ int bdiff_splitlines(const char *a, ssiz } } + if (p == plast) { + hash = HASH(hash, *p); + l->hash = hash; + l->len = p - b + 1; + l->l = b; + l->n = INT_MAX; + l++; + } + /* set up a sentinel */ l->hash = 0; l->len = 0;