]> xenbits.xensource.com Git - libvirt.git/commitdiff
virhook: Resolve Coverity NULL_RETURNS
authorJohn Ferlan <jferlan@redhat.com>
Tue, 30 Sep 2014 11:01:49 +0000 (07:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Dec 2014 16:07:31 +0000 (11:07 -0500)
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.

src/util/virhook.c

index 25d0783bfb5e16883c0c225b07b5684b3fe03d17..ee19382c4a6e655427f3a9f6898fd88e8ac42966 100644 (file)
@@ -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);