Fixed memory leak in xmld database put code

C: refactored choice validate code
This commit is contained in:
Olof hagsand 2022-12-22 17:32:40 +01:00
parent b67ef69b7f
commit 1eefadfc74
2 changed files with 123 additions and 35 deletions

View file

@ -130,8 +130,11 @@ attr_ns_value(cxobj *x,
}
}
*valp = val;
val = NULL;
retval = 1;
done:
if (val)
free(val);
return retval;
fail:
retval = 0;
@ -945,8 +948,16 @@ text_modify(clicon_handle h,
} /* else Y_CONTAINER */
retval = 1;
done:
if (valstr)
free(valstr);
if (keystr)
free(keystr);
if (instr)
free(instr);
if (opstr)
free(opstr);
if (createstr)
free(createstr);
if (nscx1)
xml_nsctx_free(nscx1);
/* Remove dangling added objects */
@ -996,7 +1007,7 @@ text_modify_top(clicon_handle h,
cxobj *x1c; /* mod child */
yang_stmt *yc; /* yang child */
yang_stmt *ymod;/* yang module */
char *opstr;
char *opstr = NULL;
int ret;
char *createstr = NULL;
@ -1121,6 +1132,8 @@ text_modify_top(clicon_handle h,
done:
if (opstr)
free(opstr);
if (createstr)
free(createstr);
return retval;
fail: /* cbret set */
retval = 0;