From 081ad7c08ca1401938f069b8bfeeae9e2f8a6a0b Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Thu, 12 Feb 2015 14:13:07 +0100 Subject: [PATCH 1/2] Add casts for the two remaining tolower() uses, since tolower() is undefined for negative character values (except for -1). Also simplify the existing casts for tolower() usages. --- src/cjson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cjson.c b/src/cjson.c index 807bd54..977fd3c 100644 --- a/src/cjson.c +++ b/src/cjson.c @@ -58,10 +58,10 @@ static int cJSON_strcasecmp( const char *s1, const char *s2 ) return ( s1 == s2 ) ? 0 : 1; if ( ! s2 ) return 1; - for ( ; tolower(*s1) == tolower(*s2); ++s1, ++s2) + for ( ; tolower((u_char)*s1) == tolower((u_char)*s2); ++s1, ++s2) if( *s1 == 0 ) return 0; - return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); + return tolower((u_char)*s1) - tolower((u_char)*s2); } From c95ee19c5939882ade312ee3bfacbd3c64edee7c Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Thu, 12 Feb 2015 15:13:00 +0100 Subject: [PATCH 2/2] Fix a toupper() usage too to avoid negative signed chars. --- src/units.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/units.c b/src/units.c index 584b048..ed1ea60 100644 --- a/src/units.c +++ b/src/units.c @@ -58,6 +58,7 @@ #include #endif #include +#include #include #include @@ -261,7 +262,7 @@ extern "C" { inNum *= 8; } - switch (toupper(inFormat)) + switch (toupper((u_char)inFormat)) { case 'B': conv = UNIT_CONV;