]> saetta.ns0.it Git - libgdaex/commitdiff
Memory leaks.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Mon, 28 Mar 2011 11:59:25 +0000 (13:59 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Mon, 28 Mar 2011 11:59:25 +0000 (13:59 +0200)
src/gdaex.c

index 859d171b5bb0c5e5c25eec651406442dab73a8f0..59d7a5eedf452815caf1ff33cacf56a731716e5b 100644 (file)
@@ -618,12 +618,14 @@ GdaDataModel
 {
        GError *error;
 
+       GdaStatement *stmt;
+       GdaDataModel *dm;
+
        g_return_val_if_fail (IS_GDAEX (gdaex), NULL);
 
        GdaExPrivate *priv = GDAEX_GET_PRIVATE (gdaex);
 
        error = NULL;
-       GdaStatement *stmt;
        stmt = gda_sql_parser_parse_string (priv->gda_parser, sql, NULL, &error);
        if (!GDA_IS_STATEMENT (stmt))
                {
@@ -639,7 +641,9 @@ GdaDataModel
                }
 
        error = NULL;
-       GdaDataModel *dm = gda_connection_statement_execute_select (priv->gda_conn, stmt, NULL, &error);
+       dm = gda_connection_statement_execute_select (priv->gda_conn, stmt, NULL, &error);
+       g_object_unref (stmt);
+
        if (!GDA_IS_DATA_MODEL (dm))
                {
                        g_warning ("Error executing selection query: %s\n%s",
@@ -654,6 +658,8 @@ GdaDataModel
                                }
                }
 
+       g_object_unref (stmt);
+
        return dm;
 }
 
@@ -1358,6 +1364,7 @@ gdaex_execute (GdaEx *gdaex, const gchar *sql)
 
        if (error != NULL)
                {
+                       g_object_unref (stmt);
                        g_warning ("Error parsing sql: %s\n%s\n",
                                   error->message != NULL ? error->message : "no details", sql);
                        return -1;
@@ -1374,6 +1381,8 @@ gdaex_execute (GdaEx *gdaex, const gchar *sql)
        error = NULL;
        nrecs = gda_connection_statement_execute_non_select (priv->gda_conn, stmt, NULL, NULL, &error);
 
+       g_object_unref (stmt);
+
        if (error != NULL)
                {
                        g_warning ("Error executing command query: %s\n%s",