fix an overflow bug in the scanner

This commit is contained in:
CK Tan 2021-07-14 20:20:15 -07:00
parent 4636173fed
commit b5818182a4

2
toml.c
View file

@ -1723,7 +1723,7 @@ static int scan_string(context_t* ctx, char* p, int lineno, int dotisspecial)
/* check for timestamp without quotes */ /* check for timestamp without quotes */
if (0 == scan_date(p, 0, 0, 0) || 0 == scan_time(p, 0, 0, 0)) { if (0 == scan_date(p, 0, 0, 0) || 0 == scan_time(p, 0, 0, 0)) {
// forward thru the timestamp // forward thru the timestamp
for ( ; strchr("0123456789.:+-T Z", toupper(*p)); p++); for ( ; *p && strchr("0123456789.:+-T Z", toupper(*p)); p++);
// squeeze out any spaces at end of string // squeeze out any spaces at end of string
for ( ; p[-1] == ' '; p--); for ( ; p[-1] == ' '; p--);
// tokenize // tokenize