]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #407: fix incorrect casts in calls to ctype functions (isdigit and isspace...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Sun, 25 Mar 2018 22:25:58 +0000 (18:25 -0400)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Sun, 25 Mar 2018 22:25:58 +0000 (18:25 -0400)
json_object.c
json_pointer.c
json_tokener.c

index 8287163a1c1d2eb5812b397e2b88459c12348c30..8a86bc6ea09a5e76995beb54c04b0af0961acfed 100644 (file)
@@ -838,7 +838,7 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
                        format_drops_decimals = 1;
 
                if (size < (int)sizeof(buf) - 2 &&
-                   isdigit((int)buf[0]) && /* Looks like *some* kind of number */
+                   isdigit((unsigned char)buf[0]) && /* Looks like *some* kind of number */
                        !p && /* Has no decimal point */
                    strchr(buf, 'e') == NULL && /* Not scientific notation */
                        format_drops_decimals)
index 2b2a9ef50732d5797c71915eb984fb4b6ba7dff3..c7e34f76f33477d073b70a1323b0f8c89eef2dcb 100644 (file)
@@ -44,7 +44,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
        /* this code-path optimizes a bit, for when we reference the 0-9 index range in a JSON array
           and because leading zeros not allowed */
        if (len == 1) {
-               if (isdigit((int)path[0])) {
+               if (isdigit((unsigned char)path[0])) {
                        *idx = (path[0] - '0');
                        goto check_oob;
                }
@@ -58,7 +58,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
        }
        /* RFC states base-10 decimals */
        for (i = 0; i < len; i++) {
-               if (!isdigit((int)path[i])) {
+               if (!isdigit((unsigned char)path[i])) {
                        errno = EINVAL;
                        return 0;
                }
index 449a82da6f568faa12644ebea6b8746009f8f680..561f7303b241894381d985f5312c22911dca882c 100644 (file)
@@ -295,7 +295,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
 
     case json_tokener_state_eatws:
       /* Advance until we change state */
-      while (isspace((int)c)) {
+      while (isspace((unsigned char)c)) {
        if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok)))
          goto out;
       }