Make sure conn exists before use it

Although all the used functions have a explicit check for a valid
virConnPtr, let's be safe and only use priv->conn when its value is
non-NULL.
This commit is contained in:
Fabiano Fidêncio 2014-11-19 05:26:58 +01:00
parent 1c69f3cf40
commit de8b381fa4

View File

@ -529,15 +529,17 @@ virt_viewer_dispose (GObject *object)
VirtViewer *self = VIRT_VIEWER(object);
VirtViewerPrivate *priv = self->priv;
if (priv->withEvents)
virConnectDomainEventDeregister(priv->conn,
virt_viewer_domain_event);
virConnectUnregisterCloseCallback(priv->conn,
virt_viewer_conn_event);
if (priv->conn) {
if (priv->withEvents)
virConnectDomainEventDeregister(priv->conn,
virt_viewer_domain_event);
virConnectUnregisterCloseCallback(priv->conn,
virt_viewer_conn_event);
virConnectClose(priv->conn);
priv->conn = NULL;
}
if (priv->dom)
virDomainFree(priv->dom);
if (priv->conn)
virConnectClose(priv->conn);
g_free(priv->uri);
priv->uri = NULL;
g_free(priv->domkey);