提交 4b4e8b57 编写于 作者: E Eric Blake

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.
上级 6e177fa1
...@@ -78,6 +78,7 @@ static int checkoutput(const char *testname) ...@@ -78,6 +78,7 @@ static int checkoutput(const char *testname)
ret = 0; ret = 0;
cleanup: cleanup:
if (actualname)
unlink(actualname); unlink(actualname);
VIR_FREE(actuallog); VIR_FREE(actuallog);
VIR_FREE(actualname); VIR_FREE(actualname);
...@@ -240,6 +241,7 @@ static int test4(const void *unused ATTRIBUTE_UNUSED) ...@@ -240,6 +241,7 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)
cleanup: cleanup:
virCommandFree(cmd); virCommandFree(cmd);
if (pidfile)
unlink(pidfile); unlink(pidfile);
VIR_FREE(pidfile); VIR_FREE(pidfile);
return ret; return ret;
...@@ -703,6 +705,7 @@ static int test18(const void *unused ATTRIBUTE_UNUSED) ...@@ -703,6 +705,7 @@ static int test18(const void *unused ATTRIBUTE_UNUSED)
cleanup: cleanup:
virCommandFree(cmd); virCommandFree(cmd);
if (pidfile)
unlink(pidfile); unlink(pidfile);
VIR_FREE(pidfile); VIR_FREE(pidfile);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册