diff -r c514b4fb5e27 -r f501322512b6 mercurial/cext/revlog.c --- a/mercurial/cext/revlog.c Fri Jun 30 03:45:57 2017 +0200 +++ b/mercurial/cext/revlog.c Fri Jul 14 13:48:17 2017 +0200 @@ -1464,7 +1464,7 @@ goto bail; } - interesting = calloc(sizeof(*interesting), 2 << revcount); + interesting = calloc(sizeof(*interesting), 1 << revcount); if (interesting == NULL) { PyErr_NoMemory(); goto bail; @@ -1481,6 +1481,8 @@ interesting[b] = 1; } + /* invariant: ninteresting is the number of non-zero entries in + * interesting. */ ninteresting = (int)revcount; for (v = maxrev; v >= 0 && ninteresting > 1; v--) { @@ -1523,8 +1525,10 @@ continue; seen[p] = nsp; interesting[sp] -= 1; - if (interesting[sp] == 0 && interesting[nsp] > 0) + if (interesting[sp] == 0) ninteresting -= 1; + if (interesting[nsp] == 0) + ninteresting += 1; interesting[nsp] += 1; } }