Browse Source

Fix build issues with SSIZE_MAX on 64bit Linux

Fix build issues with SSIZE_MAX on 64bit Linux
Fixes https://github.com/json-c/json-c/issues/638
pull/640/head
Marc GitHub 5 years ago
parent
commit
632c9f4120
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      json_object.c

+ 6
- 6
json_object.c View File

@@ -39,13 +39,13 @@
#error "The long long type isn't 64-bits"
#endif

#ifndef SSIZE_T_MAX
#ifndef SSIZE_MAX
#if SIZEOF_SSIZE_T == SIZEOF_INT
#define SSIZE_T_MAX UINT_MAX
#define SSIZE_MAX INT_MAX
#elif SIZEOF_SSIZE_T == SIZEOF_LONG
#define SSIZE_T_MAX ULONG_MAX
#define SSIZE_MAX LONG_MAX
#elif SIZEOF_SSIZE_T == SIZEOF_LONG_LONG
#define SSIZE_T_MAX ULLONG_MAX
#define SSIZE_MAX LLONG_MAX
#else
#error Unable to determine size of ssize_t
#endif
@@ -1266,7 +1266,7 @@ static struct json_object *_json_object_new_string(const char *s, const size_t l
* data
* \0]
*/
if (len > (SSIZE_T_MAX - (sizeof(*jso) - sizeof(jso->c_string)) - 1))
if (len > (SSIZE_MAX - (sizeof(*jso) - sizeof(jso->c_string)) - 1))
return NULL;
objsize = (sizeof(*jso) - sizeof(jso->c_string)) + len + 1;
if (len < sizeof(void *))
@@ -1329,7 +1329,7 @@ static int _json_object_set_string_len(json_object *jso, const char *s, size_t l
if (jso == NULL || jso->o_type != json_type_string)
return 0;

if (len >= SSIZE_T_MAX - 1)
if (len >= SSIZE_MAX - 1)
// jso->len is a signed ssize_t, so it can't hold the
// full size_t range.
return 0;


Loading…
Cancel
Save