# HG changeset patch # User Yuya Nishihara # Date 2018-09-05 12:32:45 # Node ID e85462d48cb3a59f67a595510fc7977cba6ed358 # Parent 23a00bc90a3c0082b10bbe2c8e6eedd3cc96d6f8 manifest: rewrite pathlen() to not cross entry boundary Even though the entire manifest data should be terminated by '\0', it seems not nice to scan '\0' over the entry terminator, '\n'. diff --git a/mercurial/cext/manifest.c b/mercurial/cext/manifest.c --- a/mercurial/cext/manifest.c +++ b/mercurial/cext/manifest.c @@ -42,7 +42,8 @@ typedef struct { /* get the length of the path for a line */ static size_t pathlen(line *l) { - return strlen(l->start); + const char *end = memchr(l->start, '\0', l->len); + return (end) ? (size_t)(end - l->start) : l->len; } /* get the node value of a single line */