lib: Cleanup mem-leaks in error case

When we fail to properly lookup an error code, properly cleanup
on return.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2020-11-18 08:54:51 -05:00
parent b83bb9aa62
commit 1d06fc711a

View file

@ -121,8 +121,12 @@ void log_ref_display(struct vty *vty, uint32_t code, bool json)
if (code) {
ref = log_ref_get(code);
if (!ref)
if (!ref) {
if (top)
json_object_free(top);
list_delete(&errlist);
return;
}
listnode_add(errlist, ref);
}