[virt-tools-list] [virt-viewer][PATCH 1/4 v2] Make sure conn exists before use it
Christophe Fergeau
cfergeau at redhat.com
Thu Nov 20 09:58:37 UTC 2014
ACK series except for the comment in patch #4
Christophe
On Wed, Nov 19, 2014 at 04:05:44PM +0100, Fabiano Fidêncio wrote:
> 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
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20141120/5407ab00/attachment.sig>
More information about the virt-tools-list
mailing list