memleaks
This commit is contained in:
parent
e7b60619da
commit
5f7d011654
9 changed files with 66 additions and 27 deletions
|
|
@ -665,6 +665,7 @@ xmldb_put(clicon_handle h,
|
|||
int permit = 0; /* nacm permit all */
|
||||
char *format;
|
||||
cvec *nsc = NULL; /* nacm namespace context */
|
||||
int firsttime = 0;
|
||||
|
||||
if (cbret == NULL){
|
||||
clicon_err(OE_XML, EINVAL, "cbret is NULL");
|
||||
|
|
@ -686,6 +687,7 @@ xmldb_put(clicon_handle h,
|
|||
}
|
||||
/* If there is no xml x0 tree (in cache), then read it from file */
|
||||
if (x0 == NULL){
|
||||
firsttime++; /* to avoid leakage on error, see fail from text_modify */
|
||||
if (xmldb_readfile(h, db, yspec, &x0, NULL) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -725,8 +727,14 @@ xmldb_put(clicon_handle h,
|
|||
if ((ret = text_modify_top(h, x0, x1, yspec, op, username, xnacm, permit, cbret)) < 0)
|
||||
goto done;
|
||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||
if (ret == 0)
|
||||
if (ret == 0){
|
||||
/* If first time and quit here, x0 is not written back into cache and leaks */
|
||||
if (firsttime && x0){
|
||||
xml_free(x0);
|
||||
x0 = NULL;
|
||||
}
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Remove NONE nodes if all subs recursively are also NONE */
|
||||
if (xml_tree_prune_flagged_sub(x0, XML_FLAG_NONE, 0, NULL) <0)
|
||||
|
|
|
|||
|
|
@ -2589,6 +2589,10 @@ ys_schemanode_check(yang_stmt *ys,
|
|||
yang_stmt *yp;
|
||||
char *arg;
|
||||
enum rfc_6020 keyword;
|
||||
char **vec = NULL;
|
||||
char *v;
|
||||
int nvec;
|
||||
int i;
|
||||
|
||||
yp = yang_parent_get(ys);
|
||||
arg = yang_argument_get(ys);
|
||||
|
|
@ -2609,10 +2613,6 @@ ys_schemanode_check(yang_stmt *ys,
|
|||
}
|
||||
break;
|
||||
case Y_UNIQUE:{
|
||||
char **vec = NULL;
|
||||
char *v;
|
||||
int nvec;
|
||||
int i;
|
||||
/* Unique: Sec 7.8.3 It takes as an argument a string that contains a space-
|
||||
separated list of schema node identifiers */
|
||||
if ((vec = clicon_strsep(arg, " \t\n", &nvec)) == NULL)
|
||||
|
|
@ -2643,6 +2643,8 @@ ys_schemanode_check(yang_stmt *ys,
|
|||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (vec)
|
||||
free(vec);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -3395,7 +3397,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). Is consumed
|
||||
*
|
||||
* 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)
|
||||
|
|
@ -3499,6 +3501,8 @@ ys_parse_sub(yang_stmt *ys,
|
|||
}
|
||||
retval = 0;
|
||||
done:
|
||||
if (extra)
|
||||
free(extra);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,12 +231,15 @@ yang_parse_exit(struct clicon_yang_yacc_arg *yy)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*! Pop a yang parse context on stack
|
||||
* @param[in] yy Yang yacc argument
|
||||
*/
|
||||
int
|
||||
ystack_pop(struct clicon_yang_yacc_arg *yy)
|
||||
{
|
||||
struct ys_stack *ystack;
|
||||
|
||||
if ((ystack = yy->yy_stack) == NULL){
|
||||
if ((ystack = yy->yy_stack) == NULL){
|
||||
clicon_err(OE_YANG, 0, "ystack is NULL");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -245,6 +248,10 @@ ystack_pop(struct clicon_yang_yacc_arg *yy)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*! Push a yang parse context on stack
|
||||
* @param[in] yy Yang yacc argument
|
||||
* @param[in] yn Yang node to push
|
||||
*/
|
||||
struct ys_stack *
|
||||
ystack_push(struct clicon_yang_yacc_arg *yy,
|
||||
yang_stmt *yn)
|
||||
|
|
@ -307,7 +314,13 @@ ysp_add(struct clicon_yang_yacc_arg *yy,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*! combination of ysp_add and ysp_push for sub-modules */
|
||||
/*! Add a yang statement to existing top-of-stack and then push it on stack
|
||||
*
|
||||
* @param[in] yy Yang yacc argument
|
||||
* @param[in] keyword Yang keyword
|
||||
* @param[in] argument Yang argument
|
||||
* @param[in] extra Yang extra for cornercases (unknown/extension)
|
||||
*/
|
||||
static yang_stmt *
|
||||
ysp_add_push(struct clicon_yang_yacc_arg *yy,
|
||||
enum rfc_6020 keyword,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue