diff --git a/json_object.c b/json_object.c index 026dab3..192919f 100644 --- a/json_object.c +++ b/json_object.c @@ -701,7 +701,9 @@ 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) + // INT64_MAX can't be exactly represented as a double + // so cast to tell the compiler it's ok to round up. + if (jso->o.c_double >= (double)INT64_MAX) return INT64_MAX; if (jso->o.c_double <= INT64_MIN) return INT64_MIN;