aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-05-03 10:37:13 -0600
committerEric Blake <eblake@redhat.com>2011-05-03 10:50:56 -0600
commit4b4e8b57c2a652dd7e19c04d0b06c7a7e11e6f0c (patch)
tree8b2fa1d08fafaee077dc72662384d428d51fee35 /tests/commandtest.c
parentRevert "lxc: Do not try to reconnect inactive domain when do lxcStartup" (diff)
downloadlibvirt-4b4e8b57c2a652dd7e19c04d0b06c7a7e11e6f0c.tar.gz
libvirt-4b4e8b57c2a652dd7e19c04d0b06c7a7e11e6f0c.tar.bz2
libvirt-4b4e8b57c2a652dd7e19c04d0b06c7a7e11e6f0c.zip
tests: avoid null pointer dereference
Unlikely to hit in real life, but clang noticed it. * tests/commandtest.c (checkoutput, test4, test18): Avoid unlink(NULL) on OOM.
Diffstat (limited to 'tests/commandtest.c')
-rw-r--r--tests/commandtest.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/commandtest.c b/tests/commandtest.c
index fa0061cba..caad69832 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -78,7 +78,8 @@ static int checkoutput(const char *testname)
ret = 0;
cleanup:
- unlink(actualname);
+ if (actualname)
+ unlink(actualname);
VIR_FREE(actuallog);
VIR_FREE(actualname);
VIR_FREE(expectlog);
@@ -240,7 +241,8 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
cleanup:
virCommandFree(cmd);
- unlink(pidfile);
+ if (pidfile)
+ unlink(pidfile);
VIR_FREE(pidfile);
return ret;
}
@@ -703,7 +705,8 @@ static int test18(const void *unused ATTRIBUTE_UNUSED)
cleanup:
virCommandFree(cmd);
- unlink(pidfile);
+ if (pidfile)
+ unlink(pidfile);
VIR_FREE(pidfile);
return ret;
}