diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 9528ac74..7ffdbf2b 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -531,6 +531,8 @@ from_client_unlock(clicon_handle h, ok: retval = 0; done: + if (cbx) + cbuf_free(cbx); return retval; } diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 761f2b65..301dfa0d 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -333,6 +333,8 @@ validate_identityref(cxobj *xt, } retval = 0; done: + if (cb) + cbuf_free(cb); return retval; } diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 92c4e496..173b30e5 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -326,6 +326,10 @@ xp_eval_step(xp_ctx *xc0, if (cxvec_append(xp, &xc->xc_nodeset, &xc->xc_size) < 0) goto done; } + if (vec){ + free(vec); + vec = NULL; + } break; case A_PRECEEDING: break; @@ -1080,8 +1084,10 @@ xpath_vec_ctx(cxobj *xcur, goto done; if (xp_eval(&xc, xy.xy_top, xrp) < 0) goto done; - if (xc.xc_nodeset) + if (xc.xc_nodeset){ free(xc.xc_nodeset); + xc.xc_nodeset = NULL; + } /* done: */ xpath_parse_exit(&xy); xpath_scan_exit(&xy); diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index d034798b..7008ae71 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -1616,7 +1616,6 @@ yang_parse_str(char *str, yy.yy_parse_string = str; yy.yy_stack = NULL; yy.yy_module = NULL; /* this is the return value - the module/sub-module */ - if (ystack_push(&yy, (yang_node*)yspec) == NULL) goto done; if (strlen(str)){ /* Not empty */ @@ -1640,6 +1639,8 @@ yang_parse_str(char *str, ymod = yy.yy_module; done: ystack_pop(&yy); + if (yy.yy_stack) + free (yy.yy_stack); return ymod; /* top-level (sub)module */ } @@ -2281,7 +2282,7 @@ ys_parse(yang_stmt *ys, * That is, siblings, etc, may not be there. Complete checks are made in * ys_populate instead. * @param[in] ys yang statement - * @param[in] extra Yang extra for cornercases (unknown/extension) + * @param[in] extra Yang extra for cornercases (unknown/extension). * * The cv:s created in parse-tree as follows: * fraction-digits : Create cv as uint8, check limits [1:8] (must be made in 1st pass) @@ -2335,12 +2336,11 @@ ys_parse_sub(yang_stmt *ys, clicon_err(OE_YANG, errno, "Parsing CV: %s", reason); goto done; } - free(extra); break; default: break; } - ok: + ok: retval = 0; done: if (prefix) diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 219f9766..2dc7d8f2 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -343,8 +343,9 @@ unknown_stmt : ustring ':' ustring ';' } | ustring ':' ustring ' ' string ';' { char *id; if ((id=prefix_id_join($1, $3)) == NULL) _YYERROR("0"); - if (ysp_add(_yy, Y_UNKNOWN, id, $5) == NULL) _YYERROR("0"); + if (ysp_add(_yy, Y_UNKNOWN, id, $5) == NULL){ _YYERROR("0"); } clicon_debug(2,"unknown-stmt -> ustring : ustring string"); + if ($5) free($5); } ; diff --git a/test/test_auth.sh b/test/test_auth.sh index 47679cd4..6837f8e8 100755 --- a/test/test_auth.sh +++ b/test/test_auth.sh @@ -131,7 +131,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi @@ -195,6 +195,7 @@ expecteq "$(curl -u guest:bar -sS -X PUT -d '{"x": 3}' http://localhost/restconf new "Kill restconf daemon" sudo pkill -u www-data clixon_restconf +new "Kill backend" pid=`pgrep clixon_backend` if [ -z "$pid" ]; then err "backend already dead" diff --git a/test/test_auth_ext.sh b/test/test_auth_ext.sh index 43c0aa88..c53dcf55 100755 --- a/test/test_auth_ext.sh +++ b/test/test_auth_ext.sh @@ -169,17 +169,18 @@ sudo clixon_backend -zf $cfg -y $fyang if [ $? -ne 0 ]; then err fi - +sleep 1 new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi +sleep 1 new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf -sleep 1 + new "start restconf daemon (-a is enable http basic auth)" sudo start-stop-daemon -S -q -o -b -x /www-data/clixon_restconf -d /www-data -c www-data -- -f $cfg -y $fyang -- -a @@ -246,6 +247,7 @@ expectfn "$clixon_cli -1 -U guest -l o -f $cfg -y $fyang rpc ipv4" 255 "protocol new "Kill restconf daemon" sudo pkill -u www-data clixon_restconf +new "Kill backend" pid=`pgrep clixon_backend` if [ -z "$pid" ]; then err "backend already dead" diff --git a/test/test_cli.sh b/test/test_cli.sh index 1b9adce8..716fb9d3 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -37,7 +37,8 @@ if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg" -sudo $clixon_backend -s init -f $cfg +sudo $clixon_backend -s init -f $cfg + if [ $? -ne 0 ]; then err fi diff --git a/test/test_identity.sh b/test/test_identity.sh index 3df22c73..684d7416 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -114,7 +114,7 @@ if [ $? -ne 0 ]; then fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang # -D 1 +sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1 if [ $? -ne 0 ]; then err fi diff --git a/test/test_json.sh b/test/test_json.sh index 5c33ccd3..b3f9e4d6 100755 --- a/test/test_json.sh +++ b/test/test_json.sh @@ -1,14 +1,15 @@ #!/bin/bash # Test: JSON parser tests +#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_json" PROG=../util/clixon_util_json # include err() and new() functions and creates $dir . ./lib.sh new "json parse" -expecteof $PROG 0 '{"foo": -23}' "^-23$" +expecteof "$PROG" 0 '{"foo": -23}' "^-23$" new "json parse list" -expecteof $PROG 0 '{"a":[0,1,2,3]}' "^0123$" +expecteof "$PROG" 0 '{"a":[0,1,2,3]}' "^0123$" rm -rf $dir diff --git a/test/test_leafref.sh b/test/test_leafref.sh index 30f49a78..0e93e704 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -78,7 +78,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_list.sh b/test/test_list.sh index 657b5457..25e2ee37 100755 --- a/test/test_list.sh +++ b/test/test_list.sh @@ -71,7 +71,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 1a78f1cc..a520c09a 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -76,7 +76,7 @@ if [ $? -ne 0 ]; then fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang # -D 1 +sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1 if [ $? -ne 0 ]; then err fi diff --git a/test/test_order.sh b/test/test_order.sh index aa7f3413..848e839a 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -112,7 +112,7 @@ fi new "start backend" # start new backend -sudo clixon_backend -s running -f $cfg -y $fyang +sudo $clixon_backend -s running -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_perf.sh b/test/test_perf.sh index 16f7b19a..7fe241a0 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -63,7 +63,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_restconf.sh b/test/test_restconf.sh index f4856e81..7201eb74 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -83,7 +83,7 @@ if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -y $fyang" -sudo clixon_backend -s init -f $cfg -y $fyang # -D 1 +sudo $clixon_backend -s init -f $cfg -y $fyang # -D 1 if [ $? -ne 0 ]; then err fi @@ -291,7 +291,6 @@ fi # Cant get shell macros to work, inline matching from lib.sh - new "Kill restconf daemon" sudo pkill -u www-data clixon_restconf diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index 26cf56d7..dfd7a265 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -50,7 +50,8 @@ if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -y $fyang" -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang + if [ $? -ne 0 ]; then err fi diff --git a/test/test_type.sh b/test/test_type.sh index 1535f3b3..0c1f11ef 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -144,7 +144,7 @@ if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg -y $fyang" -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_when_must.sh b/test/test_when_must.sh index dd8f2af8..ab4126e1 100755 --- a/test/test_when_must.sh +++ b/test/test_when_must.sh @@ -96,7 +96,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_xml.sh b/test/test_xml.sh index 9e4e8c70..9550c402 100755 --- a/test/test_xml.sh +++ b/test/test_xml.sh @@ -1,12 +1,13 @@ #!/bin/bash # Test: XML parser tests +#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xml" PROG=../util/clixon_util_xml # include err() and new() functions and creates $dir . ./lib.sh new "xml parse" -expecteof $PROG 0 "" "^$" +expecteof "$PROG" 0 "" "^$" XML=$(cat <An example of escaped CENDs @@ -24,7 +25,7 @@ XML=$(cat <An example of escaped CENDs +expecteof "$PROG" 0 "$XML" "^An example of escaped CENDs y\" so I guess that means that z > x ]]> ]]>]]>$" @@ -33,14 +34,14 @@ XML=$(cat <&" -expecteof $PROG 0 "$XML" "^$XML$" +expecteof "$PROG" 0 "$XML" "^$XML$" XML=$(cat <To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as " EOF ) new "xml optional encode single and double quote" -expecteof $PROG 0 "$XML" "^To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as \"$" +expecteof "$PROG" 0 "$XML" "^To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character ' may be represented as ' and the double-quote character as \"$" rm -rf $dir diff --git a/test/test_xpath.sh b/test/test_xpath.sh index b0b53a1c..d8fcca34 100755 --- a/test/test_xpath.sh +++ b/test/test_xpath.sh @@ -1,5 +1,6 @@ #!/bin/bash # Test: XPATH tests +#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_xpath" PROG=../util/clixon_util_xpath # include err() and new() functions and creates $dir diff --git a/test/test_yang.sh b/test/test_yang.sh index 8b5ec20c..7ebbbf12 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -105,7 +105,7 @@ fi new "start backend -s init -f $cfg -y $fyang" # start new backend -sudo clixon_backend -s init -f $cfg -y $fyang +sudo $clixon_backend -s init -f $cfg -y $fyang if [ $? -ne 0 ]; then err fi diff --git a/test/test_yang_parse.sh b/test/test_yang_parse.sh index c98546ca..5c3736eb 100755 --- a/test/test_yang_parse.sh +++ b/test/test_yang_parse.sh @@ -1,5 +1,6 @@ #!/bin/bash # Test: XML parser tests +#PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_yang" PROG=../util/clixon_util_yang # include err() and new() functions and creates $dir @@ -12,13 +13,13 @@ module test{ description "Example from RFC 6020"; argument "name"; } - ex:not-defined ARGUMENT; + ex:not-defined ARGUMENT;; } EOF ) new "yang parse" -expecteof $PROG 0 "$YANG" "^$YANG$" +expecteof "$PROG" 0 "$YANG" "^$YANG$" rm -rf $dir