Skip to content

Commit

Permalink
Resolved undefined behavior for isspace (#145)
Browse files Browse the repository at this point in the history
* Resolved undefined behavior for isspace

The value passed to isspace must be representable as an
unsigned char (or EOF) according to the C99 standard. The
behavior for other values is undefined.
This could cause problems for char values > 127 depending on
the signedness of char.
  • Loading branch information
cldhms authored May 21, 2021
1 parent a38184b commit 5f2cc79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Value.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ static const char* isOnlyWhitespace(const char* value)
}
for(const char* c=value;*c!='\0'; c++)
{
if(!isspace(*c))
// http://www.cplusplus.com/reference/cctype/isspace/
if(!isspace((unsigned char)*c))
{
return value;
}
Expand Down

0 comments on commit 5f2cc79

Please sign in to comment.