[PATCH] tests: avoid null pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Unlikely to hit in real life, but clang noticed it.

* tests/commandtest.c (test4): Avoid unlink(NULL) on OOM.
---

Much like a similar patch I sent for qemu_driver, but this time
the unlink(NULL) is much harder to trigger.

 tests/commandtest.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tests/commandtest.c b/tests/commandtest.c
index fa0061c..e8d8858 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -240,7 +240,8 @@ static int test4(const void *unused ATTRIBUTE_UNUSED)

 cleanup:
     virCommandFree(cmd);
-    unlink(pidfile);
+    if (pidfile)
+        unlink(pidfile);
     VIR_FREE(pidfile);
     return ret;
 }
-- 
1.7.4.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]