From 5f2cc793fa03e6ede19e4ea26bb6d730196bc9b9 Mon Sep 17 00:00:00 2001 From: cldhms <34649783+cldhms@users.noreply.github.com> Date: Fri, 21 May 2021 19:52:15 +0200 Subject: [PATCH] Resolved undefined behavior for isspace (#145) * 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. --- src/Value.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Value.c b/src/Value.c index 267a4c99..200ccca8 100644 --- a/src/Value.c +++ b/src/Value.c @@ -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; }