Allow % strings that are all numbers or %s, and fix a double free. Both

reported by George Nachman, GitHub issues 1765 and 1766.
This commit is contained in:
nicm
2019-05-31 11:34:09 +00:00
parent b26523c26d
commit 82e47403c6
2 changed files with 7 additions and 4 deletions

View File

@ -998,11 +998,15 @@ yylex(void)
if (ch == '%') {
/*
* % is a condition unless it is alone, then it is a
* token.
* % is a condition unless it is all % or all numbers,
* then it is a token.
*/
yylval.token = yylex_get_word('%');
if (strcmp(yylval.token, "%") == 0)
for (cp = yylval.token; *cp != '\0'; cp++) {
if (*cp != '%' && !isdigit((u_char)*cp))
break;
}
if (*cp == '\0')
return (TOKEN);
if (strcmp(yylval.token, "%if") == 0) {
free(yylval.token);