Mercurial > hg
changeset 39939:e85462d48cb3 stable
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'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 05 Sep 2018 21:32:45 +0900 |
parents | 23a00bc90a3c |
children | 5405cb1a7901 |
files | mercurial/cext/manifest.c |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cext/manifest.c Wed Sep 26 21:24:14 2018 +0900 +++ b/mercurial/cext/manifest.c Wed Sep 05 21:32:45 2018 +0900 @@ -42,7 +42,8 @@ /* 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 */