1 Star 0 Fork 30

orange-snn/json-c

forked from src-openEuler/json-c 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0048-json_object.c-set-errno-in-json_object_get_double.patch 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:54 . Package init
From 506a32d4ab2acbdf2315719c2ae74c40c616670b Mon Sep 17 00:00:00 2001
From: andy5995 <andy400-dev@yahoo.com>
Date: Mon, 26 Nov 2018 21:12:06 -0600
Subject: [PATCH 48/56] json_object.c:set errno in json_object_get_double()
closes #422
---
json_object.c | 11 +++++++++--
json_tokener.h | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/json_object.c b/json_object.c
index 8a86bc6..4b2b014 100644
--- a/json_object.c
+++ b/json_object.c
@@ -951,7 +951,10 @@ double json_object_get_double(const struct json_object *jso)
/* if conversion stopped at the first character, return 0.0 */
if (errPtr == get_string_component(jso))
- return 0.0;
+ {
+ errno = EINVAL;
+ return 0.0;
+ }
/*
* Check that the conversion terminated on something sensible
@@ -959,7 +962,10 @@ double json_object_get_double(const struct json_object *jso)
* For example, { "pay" : 123AB } would parse as 123.
*/
if (*errPtr != '\0')
- return 0.0;
+ {
+ errno = EINVAL;
+ return 0.0;
+ }
/*
* If strtod encounters a string which would exceed the
@@ -977,6 +983,7 @@ double json_object_get_double(const struct json_object *jso)
cdouble = 0.0;
return cdouble;
default:
+ errno = EINVAL;
return 0.0;
}
}
diff --git a/json_tokener.h b/json_tokener.h
index 8bcc6b6..4801c65 100644
--- a/json_tokener.h
+++ b/json_tokener.h
@@ -122,7 +122,7 @@ const char *json_tokener_error_desc(enum json_tokener_error jerr);
* When parsing a JSON string in pieces, if the tokener is in the middle
* of parsing this will return json_tokener_continue.
*
- * See also json_tokener_error_desc().
+ * @see json_tokener_error_desc().
*/
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
--
1.8.3.1
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

搜索帮助

0d507c66 1850385 C8b1a773 1850385