vshtabletest: Fix potential memleak

In testVshTableNew() we test whether vshTableNew(NULL) allocates
a table. This is expected to fail (and return NULL), because
passing nothing but NULL to vshTableNew() is viewed as error.
Nevertheless, if vshTableNew() did not fail and returned an
allocated table it would be leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2021-12-15 10:23:15 +01:00
parent c196179b3b
commit eb9bbde772

View File

@ -33,7 +33,9 @@
static int
testVshTableNew(const void *opaque G_GNUC_UNUSED)
{
if (vshTableNew(NULL)) {
g_autoptr(vshTable) table = vshTableNew(NULL);
if (table) {
fprintf(stderr, "expected failure when passing null to vshTableNew\n");
return -1;
}