Restconf mem leak

This commit is contained in:
Olof hagsand 2024-10-22 12:44:49 +02:00
parent 315e554637
commit fa93364953
6 changed files with 26 additions and 17 deletions

View file

@ -1202,20 +1202,24 @@ netconf_operation_not_supported_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
cxobj *x = NULL;
if (xret == NULL){
clixon_err(OE_NETCONF, EINVAL, "xret is NULL");
goto done;
}
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
if ((x = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
goto done;
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
else {
x = *xret;
if (xml_name_set(x, "rpc-reply") < 0)
goto done;
}
if (xml_add_attr(x, "xmlns", NETCONF_BASE_NAMESPACE, NULL, NULL) == NULL)
goto done;
if (xml_add_attr(*xret, "xmlns", NETCONF_BASE_NAMESPACE, NULL, NULL) == NULL)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
if ((xerr = xml_new("rpc-error", x, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>%s</error-type>"
"<error-tag>operation-not-supported</error-tag>"
@ -1225,12 +1229,17 @@ netconf_operation_not_supported_xml(cxobj **xret,
if (message){
if (xml_chardata_encode(&encstr, 0, "%s", message) < 0)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-message>%s</error-message>",
encstr) < 0)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-message>%s</error-message>",
encstr) < 0)
goto done;
}
if (x != *xret)
*xret = x;
x = NULL;
retval = 0;
done:
if (x && x != *xret)
xml_free(x);
if (encstr)
free(encstr);
return retval;

View file

@ -1533,7 +1533,6 @@ upgrade_callback_call(clixon_handle h,
{
int retval = -1;
upgrade_callback_t *uc;
int nr = 0; /* How many callbacks */
int ret;
plugin_module_struct *ms = plugin_module_struct_get(h);
@ -1564,7 +1563,6 @@ upgrade_callback_call(clixon_handle h,
}
goto fail;
}
nr++;
}
uc = NEXTQ(upgrade_callback_t *, uc);
} while (uc != ms->ms_upgrade_callbacks);

View file

@ -912,7 +912,6 @@ xml_yang_validate_unique(cxobj *xt,
yang_stmt *y;
yang_stmt *yprev = NULL;
enum rfc_6020 keyw;
int nr = 0;
int ret;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
@ -922,10 +921,8 @@ xml_yang_validate_unique(cxobj *xt,
if (keyw == Y_LIST || keyw == Y_LEAF_LIST){
/* equal: just continue*/
if (y == yprev){
nr++;
continue;
}
nr=1;
/* new list check */
switch (keyw){
case Y_LIST: