[virt-tools-list] [virt-viewer][PATCH 1/3] Make sure conn exists before use it
Fabiano Fidêncio
fidencio at redhat.com
Wed Nov 19 04:58:21 UTC 2014
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.
Related to: rhbz#1164052
https://bugzilla.redhat.com/show_bug.cgi?id=1164052
---
src/virt-viewer.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index dc16b3f..9fa2a80 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -529,15 +529,16 @@ 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);
+ }
if (priv->dom)
virDomainFree(priv->dom);
- if (priv->conn)
- virConnectClose(priv->conn);
g_free(priv->uri);
priv->uri = NULL;
g_free(priv->domkey);
--
2.1.0
More information about the virt-tools-list
mailing list