[dev@localhost net-base]$ echo '{
> "name":"test0",
> "address": [],
> "addr":"test0",
> "ethernet": {
> "switched-vlan": {
> "config": {
> "access-vlan": 210,
> "interface-mode": "ACCESS"
> }
> }
> },
> "code":"test0"
> }'|dist/bin/clixon_util_json
<name>test0</name>
=================================================================
==40140==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 728 byte(s) in 7 object(s) allocated from:
#0 0x7f6cbb523638 in __interceptor_malloc (dist/lib/libasan.so.5+0x10c638)
#1 0x7f6cbbff7690 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1084
#2 0x7f6cbbfe6a76 in json_current_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:244
#3 0x7f6cbbfe7122 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1479
#4 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#5 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#6 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#7 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 384 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb523a6e in realloc (dist/lib/libasan.so.5+0x10ca6e)
#1 0x7f6cbbff7326 in xml_child_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:970
#2 0x7f6cbbff7748 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1094
#3 0x7f6cbbfe6a76 in json_current_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:244
#4 0x7f6cbbfe7122 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1479
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 168 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb523638 in __interceptor_malloc (dist/lib/libasan.so.5+0x10c638)
#1 0x7f6cbbff7690 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1084
#2 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#3 0x7f6cbbfe70f5 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1449
#4 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#5 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#6 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#7 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 72 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb523638 in __interceptor_malloc (dist/lib/libasan.so.5+0x10c638)
#1 0x7f6cbbf9d226 in cbuf_new_alloc /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:119
#2 0x7f6cbbff6ddd in xml_value_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:692
#3 0x7f6cbbfe6c35 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:297
#4 0x7f6cbbfe70f5 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1449
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 67 byte(s) in 7 object(s) allocated from:
#0 0x7f6cbb4ac2cd in strdup (dist/lib/libasan.so.5+0x952cd)
#1 0x7f6cbbff67df in xml_name_set /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:399
#2 0x7f6cbbff7710 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1090
#3 0x7f6cbbfe6a76 in json_current_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:244
#4 0x7f6cbbfe7122 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1479
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7f6cbb523638 in __interceptor_malloc (dist/lib/libasan.so.5+0x10c638)
#1 0x7f6cbbff7690 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1084
#2 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#3 0x7f6cbbfe70c8 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1443
#4 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#5 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#6 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#7 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 38 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb523a6e in realloc (dist/lib/libasan.so.5+0x10ca6e)
#1 0x7f6cbbf9d438 in cbuf_realloc /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:216
#2 0x7f6cbbf9d679 in cbuf_append_str /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:286
#3 0x7f6cbbff6e36 in xml_value_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:697
#4 0x7f6cbbfe6c35 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:297
#5 0x7f6cbbfe70f5 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1449
#6 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#7 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#8 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#9 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 24 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb523a6e in realloc (dist/lib/libasan.so.5+0x10ca6e)
#1 0x7f6cbbff7326 in xml_child_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:970
#2 0x7f6cbbff7748 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1094
#3 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#4 0x7f6cbbfe70f5 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1449
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f6cbb523638 in __interceptor_malloc (dist/lib/libasan.so.5+0x10c638)
#1 0x7f6cbbf9d226 in cbuf_new_alloc /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:119
#2 0x7f6cbbff6ddd in xml_value_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:692
#3 0x7f6cbbfe6c35 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:297
#4 0x7f6cbbfe70c8 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1443
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 15 byte(s) in 3 object(s) allocated from:
#0 0x7f6cbb4ac2cd in strdup (dist/lib/libasan.so.5+0x952cd)
#1 0x7f6cbbff67df in xml_name_set /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:399
#2 0x7f6cbbff7710 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1090
#3 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#4 0x7f6cbbfe70f5 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1449
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7f6cbb523a6e in realloc (dist/lib/libasan.so.5+0x10ca6e)
#1 0x7f6cbbf9d438 in cbuf_realloc /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:216
#2 0x7f6cbbf9d679 in cbuf_append_str /home/dev/code/net-base/.cligen-3.6.0/cligen_buf.c:286
#3 0x7f6cbbff6e36 in xml_value_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:697
#4 0x7f6cbbfe6c35 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:297
#5 0x7f6cbbfe70c8 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1443
#6 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#7 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#8 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#9 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7f6cbb523a6e in realloc (dist/lib/libasan.so.5+0x10ca6e)
#1 0x7f6cbbff7326 in xml_child_append /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:970
#2 0x7f6cbbff7748 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1094
#3 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#4 0x7f6cbbfe70c8 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1443
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x7f6cbb4ac2cd in strdup (dist/lib/libasan.so.5+0x952cd)
#1 0x7f6cbbff67df in xml_name_set /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:399
#2 0x7f6cbbff7710 in xml_new /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_xml.c:1090
#3 0x7f6cbbfe6c10 in json_current_body /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:295
#4 0x7f6cbbfe70c8 in clixon_json_parseparse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json_parse.tab.c:1443
#5 0x7f6cbc005a9e in _json_parse /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1221
#6 0x7f6cbc006093 in clixon_json_parse_file /home/dev/code/net-base/.clixon-5.1.0/lib/src/clixon_json.c:1422
#7 0x401959 in main /home/dev/code/net-base/.clixon-5.1.0/util/clixon_util_json.c:141
#8 0x7f6cba95a554 in __libc_start_main ../csu/libc-start.c:266
SUMMARY: AddressSanitizer: 1597 byte(s) leaked in 37 allocation(s).
hi olof, there is a parse error with empry array
[]
and memory leak with json parsor. Test case is:Output is: