From 583a2a2cee12de08eefba92a00c2d67566509ba6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 11 Feb 2019 17:54:48 +0100 Subject: [PATCH] ovs: fix dispose() input and output must be freed only when not NULL. Also, ovsdb_disconnect() should do nothing if there is no client. Fixes: 830a5a14cb29ca00b73a9623c1ea7c5cd92f4d00 (cherry picked from commit 29984c07cdd6ca00831bafc23ed7604abea7569e) --- src/devices/ovs/nm-ovsdb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index 6536971102..494e2ea0fd 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -1292,6 +1292,9 @@ ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing) gpointer user_data; gs_free_error GError *error = NULL; + if (!priv->client) + return; + _LOGD ("disconnecting from ovsdb"); nm_utils_error_set_cancelled (&error, is_disposing, "NMOvsdb"); @@ -1528,11 +1531,14 @@ dispose (GObject *object) ovsdb_disconnect (self, TRUE); - g_string_free (priv->input, TRUE); - priv->input = NULL; - g_string_free (priv->output, TRUE); - priv->output = NULL; - + if (priv->input) { + g_string_free (priv->input, TRUE); + priv->input = NULL; + } + if (priv->output) { + g_string_free (priv->output, TRUE); + priv->output = NULL; + } if (priv->calls) { g_array_free (priv->calls, TRUE); priv->calls = NULL;