Browse Source

Merge pull request #361 from schwehr/int64

Fix double to int cast overflow in json_object_get_int64.
tags/json-c-0.13-20171207
Eric Haszlakiewicz GitHub 8 years ago
parent
commit
dc79d94c38
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      json_object.c

+ 4
- 0
json_object.c View File

@@ -688,6 +688,10 @@ int64_t json_object_get_int64(const struct json_object *jso)
case json_type_int:
return jso->o.c_int64;
case json_type_double:
if (jso->o.c_double >= INT64_MAX)
return INT64_MAX;
if (jso->o.c_double <= INT64_MIN)
return INT64_MIN;
return (int64_t)jso->o.c_double;
case json_type_boolean:
return jso->o.c_boolean;


Loading…
Cancel
Save