zerocopy memleak

This commit is contained in:
Olof Hagsand 2019-07-13 13:40:14 +00:00
parent c9ea6d99cf
commit 2a766c5adf

View file

@ -221,7 +221,8 @@ startup_extraxml(clicon_handle h,
int retval = -1; int retval = -1;
char *tmp_db = "tmp"; char *tmp_db = "tmp";
int ret; int ret;
cxobj *xt = NULL; /* Potentially upgraded XML */ cxobj *xt0 = NULL;
cxobj *xt = NULL;
/* Clear tmp db */ /* Clear tmp db */
if (xmldb_db_reset(h, tmp_db) < 0) if (xmldb_db_reset(h, tmp_db) < 0)
@ -242,11 +243,10 @@ startup_extraxml(clicon_handle h,
* It should be empty if extra-xml is null and reset plugins did nothing * It should be empty if extra-xml is null and reset plugins did nothing
* then skip validation. * then skip validation.
*/ */
if (xmldb_get(h, tmp_db, NULL, &xt) < 0) if (xmldb_get(h, tmp_db, NULL, &xt0) < 0)
goto done; goto done;
if (xt==NULL || xml_child_nr(xt)==0) if (xt0==NULL || xml_child_nr(xt0)==0)
goto ok; goto ok;
xml_free(xt);
xt = NULL; xt = NULL;
/* Validate the tmp db and return possibly upgraded xml in xt /* Validate the tmp db and return possibly upgraded xml in xt
*/ */
@ -264,6 +264,8 @@ startup_extraxml(clicon_handle h,
ok: ok:
retval = 1; retval = 1;
done: done:
if (xt0)
xml_free(xt0);
xmldb_get0_free(h, &xt); xmldb_get0_free(h, &xt);
if (xmldb_delete(h, tmp_db) != 0 && errno != ENOENT) if (xmldb_delete(h, tmp_db) != 0 && errno != ENOENT)
return -1; return -1;