[virt-tools-list] [virt-viewer][PATCH 1/4 v2] Make sure conn exists before use it
Fabiano Fidêncio
fidencio at redhat.com
Wed Nov 19 15:05:44 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.
---
Changes since v1:
- Set priv->conn to NULL
---
src/virt-viewer.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index dc16b3f..02385db 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -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);
--
2.1.0
More information about the virt-tools-list
mailing list