1 Star 0 Fork 31

orange-snn/json-c

forked from src-openEuler/json-c 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
json-c-bugfix-against-INT64_MAX.patch 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
orange-snn 提交于 2020-03-03 17:22 . bugfix in oss-fuzz
From d0b87ee87b282e9b91a1af924050e217b0b2ae8b Mon Sep 17 00:00:00 2001
From: Eric Haszlakiewicz <erh+git@nimenees.com>
Date: Mon, 12 Aug 2019 00:30:45 +0000
Subject: [PATCH] Add an explicit cast to double to squash a
-Wimplicit-int-float-conversion warning. Though we will no longer be
comparing exactly against INT64_MAX, this is ok because any value of that
magnitude stored in a double will *also* have been rounded up, so the
comparison will work appropriately.
---
json_object.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/json_object.c b/json_object.c
index 026dab313b..192919f460 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;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/orange-snn/json-c.git
git@gitee.com:orange-snn/json-c.git
orange-snn
json-c
json-c
master

搜索帮助