diff --git a/src/util/virerror.c b/src/util/virerror.c index 5d875e37766b0cb597472508d77c1ef1ba57c159..1177570ef0d540249302ca14cb5ea00d0681c962 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -281,9 +281,9 @@ const char * virGetLastErrorMessage(void) { virErrorPtr err = virLastErrorObject(); - if (!err || err->code == VIR_ERR_OK) + if (err && err->code == VIR_ERR_OK) return _("no error"); - if (err->message == NULL) + if (!err || !err->message) return _("unknown error"); return err->message; }