[libvirt] [PATCH 2/4] virhook: Resolve Coverity NULL_RETURNS

John Ferlan jferlan at redhat.com
Mon Dec 1 16:33:55 UTC 2014


Coverity complains that many other callers to return err from
virGetLastError() will check if err is not NULL before dereferencing
it.  Just do the same here for safety.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/util/virhook.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virhook.c b/src/util/virhook.c
index 25d0783..ee19382 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -300,7 +300,8 @@ virHookCall(int driver,
     if (ret < 0) {
         /* Convert INTERNAL_ERROR into known error.  */
         virErrorPtr err = virGetLastError();
-        virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s", err->message);
+        virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s",
+                       err ? err->message : _("unknown error"));
     }
 
     virCommandFree(cmd);
-- 
1.9.3




More information about the libvir-list mailing list