[libgda] Fix some memory leaks
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Fix some memory leaks
- Date: Sun, 7 Apr 2013 20:27:11 +0000 (UTC)
commit 569a6e8d8f794f5e0d4a5799df0239c15275da09
Author: Miguel Angel Cabrera Moya <madmac2501 gmail com>
Date: Sun Apr 7 21:35:02 2013 +0200
Fix some memory leaks
libgda/gda-config.c | 3 +++
libgda/gda-connection.c | 4 +++-
libgda/gda-data-model-import.c | 1 +
libgda/gda-data-model.c | 2 ++
libgda/gda-data-proxy.c | 5 ++++-
libgda/gda-data-select.c | 1 +
libgda/gda-meta-store.c | 4 +++-
libgda/gda-meta-struct-io.c | 5 ++++-
libgda/gda-value.c | 6 ++++++
9 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index a0af3ae..752c611 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -705,6 +705,7 @@ gda_config_constructor (GType type,
gda_log_message (_("User specific "
"configuration directory '%s' exists and is not a
directory"),
confdir);
+ g_free (conffile);
}
else
unique_instance->priv->user_file = conffile;
@@ -1653,6 +1654,7 @@ load_all_providers (void)
gchar *pdir;
pdir = g_build_path (G_DIR_SEPARATOR_S, dirname, "providers", NULL);
load_providers_from_dir (pdir, TRUE);
+ g_free (pdir);
}
else {
gchar *str;
@@ -1825,6 +1827,7 @@ load_providers_from_dir (const gchar *dirname, gboolean recurs)
}
else {
g_module_close (handle);
+ g_free (path);
continue;
}
g_module_symbol (handle, "plugin_get_name",
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index f97f3af..4e0c332 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -1613,7 +1613,9 @@ gda_connection_open_sqlite (const gchar *directory, const gchar *filename, gbool
g_object_set_data_full (G_OBJECT (cnc), "__gda_fname", fname, g_free);
g_signal_connect (cnc, "conn-closed",
G_CALLBACK (sqlite_connection_closed_cb), NULL);
- }
+ } else {
+ g_free (fname);
+ }
return cnc;
}
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index 7db18fe..651519e 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -1019,6 +1019,7 @@ csv_parser_field_read_cb (char *s, size_t len, void *data)
if (! model->priv->extract.csv.initializing) {
if (pdata->field_next_col >= pdata->nb_cols)
/* ignore extra fields */
+ g_free (copy);
return;
column = gda_data_model_describe_column ((GdaDataModel *) model,
pdata->field_next_col);
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 1c47a93..8ddcbc0 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -2023,6 +2023,8 @@ add_xml_row (GdaDataModel *model, xmlNodePtr xml_row, GError **error)
if (g_ptr_array_index (values, i))
gda_value_free ((GValue *) g_ptr_array_index (values, i));
+ g_ptr_array_unref (values);
+
return retval;
}
diff --git a/libgda/gda-data-proxy.c b/libgda/gda-data-proxy.c
index 736055d..cbcdb29 100644
--- a/libgda/gda-data-proxy.c
+++ b/libgda/gda-data-proxy.c
@@ -3336,7 +3336,9 @@ gda_data_proxy_set_ordering_column (GdaDataProxy *proxy, gint col, GError **erro
order_by->asc = TRUE;
expr->value = gda_value_new (G_TYPE_STRING);
g_value_take_string (expr->value, colname);
- }
+ } else {
+ g_free (colname);
+ }
g_object_set (G_OBJECT (proxy->priv->filter_stmt), "structure", sqlst, NULL);
#ifdef GDA_DEBUG_NO
@@ -3352,6 +3354,7 @@ gda_data_proxy_set_ordering_column (GdaDataProxy *proxy, gint col, GError **erro
gchar *str;
str = g_strdup_printf ("ORDER BY _%d", col + 1);
retval = gda_data_proxy_set_filter_expr (proxy, str, error);
+ g_free (str);
}
gda_mutex_unlock (proxy->priv->mutex);
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index 3bf3967..5dc6b6e 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -3711,6 +3711,7 @@ gda_data_select_rerun (GdaDataSelect *model, GError **error)
memcpy (copy, (gint8*) new_model + offset, size); /* Flawfinder: ignore */
memcpy ((gint8*) new_model + offset, (gint8*) model + offset, size); /* Flawfinder: ignore */
memcpy ((gint8*) model + offset, copy, size); /* Flawfinder: ignore */
+ g_free (copy);
/* we need to keep some data from the old model */
GdaDataSelectInternals *mi;
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 56be4cb..c855e5d 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -3565,8 +3565,10 @@ prepare_tables_infos (GdaMetaStore *store, TableInfo **out_table_infos, TableCon
*out_cond_infos = g_hash_table_lookup (klass->cpriv->table_cond_info_hash, key);
if (! *out_cond_infos) {
*out_cond_infos = create_custom_set (store, table_name, condition, error);
- if (! *out_cond_infos)
+ if (! *out_cond_infos) {
+ g_free (key);
return FALSE;
+ }
g_hash_table_insert (klass->cpriv->table_cond_info_hash, key, *out_cond_infos);
}
else
diff --git a/libgda/gda-meta-struct-io.c b/libgda/gda-meta-struct-io.c
index f521cd7..e9d619c 100644
--- a/libgda/gda-meta-struct-io.c
+++ b/libgda/gda-meta-struct-io.c
@@ -169,6 +169,7 @@ create_table_object (GdaMetaStruct *mstruct, const GValue *catalog, const gchar
xmlChar *table_name, *table_schema;
GString *full_table_name;
GValue *v1 = NULL, *v2 = NULL, *v3 = NULL;
+ GArray *pk_cols_array = NULL;
gchar *tmp;
table_name = xmlGetProp (node, BAD_CAST "name");
@@ -220,7 +221,7 @@ create_table_object (GdaMetaStruct *mstruct, const GValue *catalog, const gchar
/* walk through the columns and Fkey nodes */
GdaMetaTable *mtable = GDA_META_TABLE (dbobj);
xmlNodePtr cnode;
- GArray *pk_cols_array = g_array_new (FALSE, FALSE, sizeof (gint));
+ pk_cols_array = g_array_new (FALSE, FALSE, sizeof (gint));
gint colsindex = 0;
for (cnode = node->children; cnode; cnode = cnode->next) {
if (!strcmp ((gchar *) cnode->name, "column")) {
@@ -407,6 +408,8 @@ create_table_object (GdaMetaStruct *mstruct, const GValue *catalog, const gchar
if (v2) gda_value_free (v2);
gda_value_free (v3);
+ if (pk_cols_array) g_array_unref (pk_cols_array);
+
return NULL;
}
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 2d865b4..e79ac57 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -867,13 +867,19 @@ GdaNumeric*
gda_numeric_copy (GdaNumeric *src)
{
GdaNumeric *copy;
+ gchar *str;
g_return_val_if_fail (src, NULL);
copy = gda_numeric_new ();
+
+ str = gda_numeric_get_string (src);
gda_numeric_set_from_string (copy, gda_numeric_get_string (src));
+ g_free (str);
+
gda_numeric_set_width (copy, gda_numeric_get_width (src));
gda_numeric_set_precision (copy, gda_numeric_get_precision (src));
+
return copy;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]