Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
737e854c
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
大约 1 年 前同步成功
通知
6
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party CJSON
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
737e854c
编写于
6月 16, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
!27 update version to v1.7.15
Merge pull request !27 from piggyguy_jdx/update-cjson-version
上级
7d2f0c54
6b94bd09
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
99 addition
and
19 deletion
+99
-19
CHANGELOG.md
CHANGELOG.md
+10
-0
CMakeLists.txt
CMakeLists.txt
+1
-1
Makefile
Makefile
+1
-1
README.OpenSource
README.OpenSource
+1
-1
cJSON.c
cJSON.c
+26
-11
cJSON.h
cJSON.h
+2
-2
cJSON_Utils.c
cJSON_Utils.c
+7
-1
tests/cjson_add.c
tests/cjson_add.c
+49
-0
tests/json_patch_tests.c
tests/json_patch_tests.c
+1
-1
tests/readme_examples.c
tests/readme_examples.c
+1
-1
未找到文件。
CHANGELOG.md
浏览文件 @
737e854c
1.7.15 (Aug 25, 2021)
======
Fixes:
------
*
Fix potential core dumped for strrchr, see
[
#546
](
https://github.com/DaveGamble/cJSON/pull/546
)
*
Fix null pointer crash in cJSON_CreateXxArray, see
[
#538
](
https://github.com/DaveGamble/cJSON/pull/538
)
*
Fix several null pointer problems on allocation failure, see
[
#526
](
https://github.com/DaveGamble/cJSON/pull/526
)
*
Fix a possible dereference of null pointer, see
[
#519
](
https://github.com/DaveGamble/cJSON/pull/519
)
*
Fix windows build failure about defining nan, see
[
#518
](
https://github.com/DaveGamble/cJSON/pull/518
)
1.
7.14 (Sep 3, 2020)
======
Fixes:
...
...
CMakeLists.txt
浏览文件 @
737e854c
...
...
@@ -7,7 +7,7 @@ include(GNUInstallDirs)
set
(
PROJECT_VERSION_MAJOR 1
)
set
(
PROJECT_VERSION_MINOR 7
)
set
(
PROJECT_VERSION_PATCH 1
4
)
set
(
PROJECT_VERSION_PATCH 1
5
)
set
(
CJSON_VERSION_SO 1
)
set
(
CJSON_UTILS_VERSION_SO 1
)
set
(
PROJECT_VERSION
"
${
PROJECT_VERSION_MAJOR
}
.
${
PROJECT_VERSION_MINOR
}
.
${
PROJECT_VERSION_PATCH
}
"
)
...
...
Makefile
浏览文件 @
737e854c
...
...
@@ -8,7 +8,7 @@ CJSON_TEST_SRC = cJSON.c test.c
LDLIBS
=
-lm
LIBVERSION
=
1.7.1
4
LIBVERSION
=
1.7.1
5
CJSON_SOVERSION
=
1
UTILS_SOVERSION
=
1
...
...
README.OpenSource
浏览文件 @
737e854c
...
...
@@ -3,7 +3,7 @@
"Name": "cJSON",
"License": "MIT License",
"License File": "LICENSE",
"Version Number": "1.7.1
4
",
"Version Number": "1.7.1
5
",
"Owner": "lizhiqi1@huawei.com",
"Upstream URL": "https://github.com/DaveGamble/cJSON/releases",
"Description": "Ultralightweight JSON parser in ANSI C."
...
...
cJSON.c
浏览文件 @
737e854c
...
...
@@ -78,8 +78,12 @@
#endif
#ifndef NAN
#ifdef _WIN32
#define NAN sqrt(-1.0)
#else
#define NAN 0.0/0.0
#endif
#endif
typedef
struct
{
const
unsigned
char
*
json
;
...
...
@@ -113,7 +117,7 @@ CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
}
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 1
4
)
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 1
5
)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif
...
...
@@ -507,10 +511,8 @@ static unsigned char* ensure(printbuffer * const p, size_t needed)
return
NULL
;
}
if
(
newbuffer
)
{
memcpy
(
newbuffer
,
p
->
buffer
,
p
->
offset
+
1
);
}
memcpy
(
newbuffer
,
p
->
buffer
,
p
->
offset
+
1
);
p
->
hooks
.
deallocate
(
p
->
buffer
);
}
p
->
length
=
newsize
;
...
...
@@ -2544,6 +2546,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
}
a
=
cJSON_CreateArray
();
for
(
i
=
0
;
a
&&
(
i
<
(
size_t
)
count
);
i
++
)
{
n
=
cJSON_CreateNumber
(
numbers
[
i
]);
...
...
@@ -2562,7 +2565,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
}
p
=
n
;
}
a
->
child
->
prev
=
n
;
if
(
a
&&
a
->
child
)
{
a
->
child
->
prev
=
n
;
}
return
a
;
}
...
...
@@ -2599,7 +2605,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
}
p
=
n
;
}
a
->
child
->
prev
=
n
;
if
(
a
&&
a
->
child
)
{
a
->
child
->
prev
=
n
;
}
return
a
;
}
...
...
@@ -2618,7 +2627,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
a
=
cJSON_CreateArray
();
for
(
i
=
0
;
a
&&
(
i
<
(
size_t
)
count
);
i
++
)
for
(
i
=
0
;
a
&&
(
i
<
(
size_t
)
count
);
i
++
)
{
n
=
cJSON_CreateNumber
(
numbers
[
i
]);
if
(
!
n
)
...
...
@@ -2636,7 +2645,10 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
}
p
=
n
;
}
a
->
child
->
prev
=
n
;
if
(
a
&&
a
->
child
)
{
a
->
child
->
prev
=
n
;
}
return
a
;
}
...
...
@@ -2673,8 +2685,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
}
p
=
n
;
}
a
->
child
->
prev
=
n
;
if
(
a
&&
a
->
child
)
{
a
->
child
->
prev
=
n
;
}
return
a
;
}
...
...
@@ -2961,7 +2976,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item)
CJSON_PUBLIC
(
cJSON_bool
)
cJSON_Compare
(
const
cJSON
*
const
a
,
const
cJSON
*
const
b
,
const
cJSON_bool
case_sensitive
)
{
if
((
a
==
NULL
)
||
(
b
==
NULL
)
||
((
a
->
type
&
0xFF
)
!=
(
b
->
type
&
0xFF
))
||
cJSON_IsInvalid
(
a
)
)
if
((
a
==
NULL
)
||
(
b
==
NULL
)
||
((
a
->
type
&
0xFF
)
!=
(
b
->
type
&
0xFF
)))
{
return
false
;
}
...
...
cJSON.h
浏览文件 @
737e854c
...
...
@@ -81,7 +81,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 1
4
#define CJSON_VERSION_PATCH 1
5
#include <stddef.h>
...
...
@@ -256,7 +256,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
* The input pointer json cannot point to a read-only address area, such as a string constant,
* but should point to a readable and writable adress area. */
* but should point to a readable and writable ad
d
ress area. */
CJSON_PUBLIC
(
void
)
cJSON_Minify
(
char
*
json
);
/* Helper functions for creating and adding items to an object at the same time.
...
...
cJSON_Utils.c
浏览文件 @
737e854c
...
...
@@ -960,7 +960,9 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_
/* split pointer in parent and child */
parent_pointer
=
cJSONUtils_strdup
((
unsigned
char
*
)
path
->
valuestring
);
child_pointer
=
(
unsigned
char
*
)
strrchr
((
char
*
)
parent_pointer
,
'/'
);
if
(
parent_pointer
)
{
child_pointer
=
(
unsigned
char
*
)
strrchr
((
char
*
)
parent_pointer
,
'/'
);
}
if
(
child_pointer
!=
NULL
)
{
child_pointer
[
0
]
=
'\0'
;
...
...
@@ -1406,6 +1408,10 @@ static cJSON *generate_merge_patch(cJSON * const from, cJSON * const to, const c
from_child
=
from
->
child
;
to_child
=
to
->
child
;
patch
=
cJSON_CreateObject
();
if
(
patch
==
NULL
)
{
return
NULL
;
}
while
(
from_child
||
to_child
)
{
int
diff
;
...
...
tests/cjson_add.c
浏览文件 @
737e854c
...
...
@@ -117,6 +117,50 @@ static void cjson_add_true_should_fail_on_allocation_failure(void)
cJSON_Delete
(
root
);
}
static
void
cjson_create_int_array_should_fail_on_allocation_failure
(
void
)
{
int
numbers
[]
=
{
1
,
2
,
3
};
cJSON_InitHooks
(
&
failing_hooks
);
TEST_ASSERT_NULL
(
cJSON_CreateIntArray
(
numbers
,
3
));
cJSON_InitHooks
(
NULL
);
}
static
void
cjson_create_float_array_should_fail_on_allocation_failure
(
void
)
{
float
numbers
[]
=
{
1
.
0
f
,
2
.
0
f
,
3
.
0
f
};
cJSON_InitHooks
(
&
failing_hooks
);
TEST_ASSERT_NULL
(
cJSON_CreateFloatArray
(
numbers
,
3
));
cJSON_InitHooks
(
NULL
);
}
static
void
cjson_create_double_array_should_fail_on_allocation_failure
(
void
)
{
double
numbers
[]
=
{
1
.
0
,
2
.
0
,
3
.
0
};
cJSON_InitHooks
(
&
failing_hooks
);
TEST_ASSERT_NULL
(
cJSON_CreateDoubleArray
(
numbers
,
3
));
cJSON_InitHooks
(
NULL
);
}
static
void
cjson_create_string_array_should_fail_on_allocation_failure
(
void
)
{
const
char
*
strings
[]
=
{
"1"
,
"2"
,
"3"
};
cJSON_InitHooks
(
&
failing_hooks
);
TEST_ASSERT_NULL
(
cJSON_CreateStringArray
(
strings
,
3
));
cJSON_InitHooks
(
NULL
);
}
static
void
cjson_add_false_should_add_false
(
void
)
{
cJSON
*
root
=
cJSON_CreateObject
();
...
...
@@ -390,6 +434,11 @@ int CJSON_CDECL main(void)
RUN_TEST
(
cjson_add_true_should_fail_with_null_pointers
);
RUN_TEST
(
cjson_add_true_should_fail_on_allocation_failure
);
RUN_TEST
(
cjson_create_int_array_should_fail_on_allocation_failure
);
RUN_TEST
(
cjson_create_float_array_should_fail_on_allocation_failure
);
RUN_TEST
(
cjson_create_double_array_should_fail_on_allocation_failure
);
RUN_TEST
(
cjson_create_string_array_should_fail_on_allocation_failure
);
RUN_TEST
(
cjson_add_false_should_add_false
);
RUN_TEST
(
cjson_add_false_should_fail_with_null_pointers
);
RUN_TEST
(
cjson_add_false_should_fail_on_allocation_failure
);
...
...
tests/json_patch_tests.c
浏览文件 @
737e854c
...
...
@@ -66,7 +66,7 @@ static cJSON_bool test_apply_patch(const cJSON * const test)
}
else
{
printf
(
"Testing unkown
\n
"
);
printf
(
"Testing unk
n
own
\n
"
);
}
disabled
=
cJSON_GetObjectItemCaseSensitive
(
test
,
"disabled"
);
...
...
tests/readme_examples.c
浏览文件 @
737e854c
...
...
@@ -69,7 +69,7 @@ static char* create_monitor(void)
goto
end
;
}
/* after creation was successful, immediately add it to the monitor,
* thereby transfering ownership of the pointer to it */
* thereby transfer
r
ing ownership of the pointer to it */
cJSON_AddItemToObject
(
monitor
,
"name"
,
name
);
resolutions
=
cJSON_CreateArray
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录