[libgda] GdaConnection: fix double free at finalize



commit 1bda068d1314d09686d9396239f8274d69960801
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Mon Feb 25 16:10:01 2019 -0600

    GdaConnection: fix double free at finalize

 libgda/gda-connection.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index e140fabb9..ef2e22fa1 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -139,7 +139,6 @@ static void add_exec_time_to_object (GObject *obj, GTimer *timer);
 static void gda_connection_class_init (GdaConnectionClass *klass);
 static void gda_connection_init       (GdaConnection *cnc);
 static void gda_connection_dispose    (GObject *object);
-static void gda_connection_finalize   (GObject *object);
 static void gda_connection_set_property (GObject *object,
                                         guint param_id,
                                         const GValue *value,
@@ -388,7 +387,6 @@ gda_connection_class_init (GdaConnectionClass *klass)
                                                            (G_PARAM_READABLE | G_PARAM_WRITABLE)));
 
        object_class->dispose = gda_connection_dispose;
-       object_class->finalize = gda_connection_finalize;
 
        /* computing debug level */
        if (debug_level == -1) {
@@ -534,30 +532,23 @@ gda_connection_dispose (GObject *object)
                g_array_free (priv->trans_meta_context, TRUE);
                priv->trans_meta_context = NULL;
        }
+       if (priv->dsn) {
+               g_free (priv->dsn);
+               priv->dsn = NULL;
+       }
+       if (priv->cnc_string) {
+               g_free (priv->cnc_string);
+               priv->cnc_string = NULL;
+       }
+       if (priv->auth_string) {
+               g_free (priv->auth_string);
+               priv->auth_string = NULL;
+       }
 
        /* chain to parent class */
   G_OBJECT_CLASS (gda_connection_parent_class)->dispose (object);
 }
 
-static void
-gda_connection_finalize (GObject *object)
-{
-       GdaConnection *cnc = (GdaConnection *) object;
-
-       g_return_if_fail (GDA_IS_CONNECTION (cnc));
-       GdaConnectionPrivate *priv = gda_connection_get_instance_private (cnc);
-
-       /* free memory */
-       g_free (priv->dsn);
-       g_free (priv->cnc_string);
-       g_free (priv->auth_string);
-
-       g_rec_mutex_clear (&priv->rmutex);
-
-       /* chain to parent class */
-  G_OBJECT_CLASS (gda_connection_parent_class)->finalize (object);
-}
-
 /* module error */
 GQuark gda_connection_error_quark (void)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]