--- a/mercurial/cext/dirs.c Thu Jul 13 23:43:16 2017 -0700 +++ b/mercurial/cext/dirs.c Tue May 16 11:00:38 2017 -0700 @@ -42,6 +42,9 @@ break; pos -= 1; } + if (pos == -1) { + return 0; + } return pos; }