Do not risk writing over the end of the buffer when it ends in #

(because strchr \0 will be non-NULL), reported by Robert Morris in
GitHub issue 3610.
pull/3621/head
nicm 2023-07-03 10:48:26 +00:00
parent e79fb214f8
commit ac43186dff
1 changed files with 3 additions and 1 deletions

View File

@ -3664,7 +3664,9 @@ format_skip(const char *s, const char *end)
for (; *s != '\0'; s++) {
if (*s == '#' && s[1] == '{')
brackets++;
if (*s == '#' && strchr(",#{}:", s[1]) != NULL) {
if (*s == '#' &&
s[1] != '\0' &&
strchr(",#{}:", s[1]) != NULL) {
s++;
continue;
}