[libgda] Misc. corrections for bugs discovered by CoverityScan
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Misc. corrections for bugs discovered by CoverityScan
- Date: Thu, 30 Aug 2012 20:15:01 +0000 (UTC)
commit 1f42bd6f8fb030b01396ebe267ba0056c70b6326
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Aug 30 22:14:50 2012 +0200
Misc. corrections for bugs discovered by CoverityScan
libgda-ui/data-entries/plugins/gdaui-entry-cidr.c | 2 +-
libgda-ui/internal/gdaui-provider-spec-editor.c | 8 ++--
libgda/dir-blob-op.c | 1 +
libgda/gda-meta-store.c | 34 +++++++++++----------
libgda/sqlite/mkkeywordhash.c | 3 +-
providers/firebird/gda-firebird-provider.c | 6 +++-
providers/jdbc/gda-jdbc-provider.c | 2 +-
providers/oracle/gda-oracle-util.c | 2 +-
providers/reuseable/postgres/gda-postgres-meta.c | 2 +-
testing/gda-provider-status.c | 2 +-
10 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/libgda-ui/data-entries/plugins/gdaui-entry-cidr.c b/libgda-ui/data-entries/plugins/gdaui-entry-cidr.c
index b45252f..1034d73 100644
--- a/libgda-ui/data-entries/plugins/gdaui-entry-cidr.c
+++ b/libgda-ui/data-entries/plugins/gdaui-entry-cidr.c
@@ -332,7 +332,7 @@ real_set_value (GdauiEntryWrapper *mgwrap, const GValue *value)
gdaui_entry_set_text (GDAUI_ENTRY (mgcidr->priv->entry), NULL);
else {
SplitValues *svalues;
- gchar *str, *ptr, *tok;
+ gchar *str, *ptr, *tok = NULL;
gint i=1;
str = g_strdup (g_value_get_string ((GValue *) value));
diff --git a/libgda-ui/internal/gdaui-provider-spec-editor.c b/libgda-ui/internal/gdaui-provider-spec-editor.c
index e836cd2..1a031b6 100644
--- a/libgda-ui/internal/gdaui-provider-spec-editor.c
+++ b/libgda-ui/internal/gdaui-provider-spec-editor.c
@@ -202,9 +202,9 @@ adapt_form_widget (GdauiProviderSpecEditor *spec)
/* create new widget */
GdaSet *dset;
- GtkWidget *wid;
dset = gda_set_copy (pinfo->dsn_params);
if (dset) {
+ GtkWidget *wid;
spec->priv->type = PROVIDER_FORM;
wid = gdaui_basic_form_new (dset);
@@ -221,10 +221,10 @@ adapt_form_widget (GdauiProviderSpecEditor *spec)
update_form_contents (spec);
g_signal_connect (G_OBJECT (wid), "holder-changed",
G_CALLBACK (dsn_form_changed), spec);
- }
- gtk_widget_show (wid);
- gtk_container_add (GTK_CONTAINER (spec), wid);
+ gtk_widget_show (wid);
+ gtk_container_add (GTK_CONTAINER (spec), wid);
+ }
}
diff --git a/libgda/dir-blob-op.c b/libgda/dir-blob-op.c
index 3b0886a..bffab30 100644
--- a/libgda/dir-blob-op.c
+++ b/libgda/dir-blob-op.c
@@ -256,6 +256,7 @@ gda_dir_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
tmp_written = fwrite ((char *) (bin->data), sizeof (guchar), bin->binary_length, file);
if (tmp_written < bin->binary_length) {
/* error writing stream */
+ fclose (file);
gda_blob_free ((gpointer) tmpblob);
return -1;
}
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index ff5217d..fc3ff36 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -2250,23 +2250,25 @@ complement_db_objects (GSList *objects, G_GNUC_UNUSED GHashTable *hash, GError *
static void
db_object_free (DbObject *dbobj)
{
- g_free (dbobj->obj_name);
- if (dbobj->create_op)
- g_object_unref (dbobj->create_op);
- if (dbobj->depend_list)
- g_slist_free (dbobj->depend_list);
- switch (dbobj->obj_type) {
- case GDA_SERVER_OPERATION_CREATE_TABLE:
- table_info_free_contents (TABLE_INFO (dbobj));
- break;
- case GDA_SERVER_OPERATION_CREATE_VIEW:
- view_info_free_contents (VIEW_INFO (dbobj));
- break;
- default:
- TO_IMPLEMENT;
- break;
+ if (dbobj) {
+ g_free (dbobj->obj_name);
+ if (dbobj->create_op)
+ g_object_unref (dbobj->create_op);
+ if (dbobj->depend_list)
+ g_slist_free (dbobj->depend_list);
+ switch (dbobj->obj_type) {
+ case GDA_SERVER_OPERATION_CREATE_TABLE:
+ table_info_free_contents (TABLE_INFO (dbobj));
+ break;
+ case GDA_SERVER_OPERATION_CREATE_VIEW:
+ view_info_free_contents (VIEW_INFO (dbobj));
+ break;
+ default:
+ TO_IMPLEMENT;
+ break;
+ }
+ g_free (dbobj);
}
- g_free (dbobj);
}
static void
diff --git a/libgda/sqlite/mkkeywordhash.c b/libgda/sqlite/mkkeywordhash.c
index 536d255..5c6276f 100644
--- a/libgda/sqlite/mkkeywordhash.c
+++ b/libgda/sqlite/mkkeywordhash.c
@@ -155,7 +155,7 @@ parse_input (const char *filename)
{
#define BUFSIZE 500
FILE *stream;
- char buffer[BUFSIZE];
+ char buffer[BUFSIZE+1];
int read;
char *end;
@@ -169,6 +169,7 @@ parse_input (const char *filename)
memset (aKeywordTable, 0, sizeof (Keyword) * MAXKEYWORDS);
read = fread (buffer, 1, BUFSIZE, stream);
end = buffer + read;
+ *end = 0;
while (read > 0) {
char *ptr;
diff --git a/providers/firebird/gda-firebird-provider.c b/providers/firebird/gda-firebird-provider.c
index ec09c39..4a80ac0 100644
--- a/providers/firebird/gda-firebird-provider.c
+++ b/providers/firebird/gda-firebird-provider.c
@@ -1695,19 +1695,23 @@ gda_firebird_provider_statement_execute (GdaServerProvider *provider,
*/
}
else {
- gchar *str;
GdaDataHandler *data_handler =
gda_server_provider_get_data_handler_g_type (provider, cnc,
G_VALUE_TYPE (value));
if (data_handler == NULL) {
/* there is an error here */
+ gchar *str;
event = gda_connection_point_available_event (cnc, GDA_CONNECTION_EVENT_ERROR);
+ str = g_strdup_printf (_("Unhandled data type '%s'"),
+ gda_g_type_to_string (G_VALUE_TYPE (value)));
gda_connection_event_set_description (event, str);
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
GDA_SERVER_PROVIDER_DATA_ERROR, "%s", str);
+ g_free (str);
break;
}
else {
+ gchar *str;
short *flag0 = g_new0 (short, 1);
mem_to_free = g_slist_prepend (mem_to_free, flag0);
diff --git a/providers/jdbc/gda-jdbc-provider.c b/providers/jdbc/gda-jdbc-provider.c
index b7b189e..b66da03 100644
--- a/providers/jdbc/gda-jdbc-provider.c
+++ b/providers/jdbc/gda-jdbc-provider.c
@@ -1083,7 +1083,7 @@ gda_jdbc_provider_statement_prepare (GdaServerProvider *provider, GdaConnection
/* prepare @stmt using the C API, creates @ps */
GValue *pstmt_obj;
JNIEnv *jenv = NULL;
- gboolean jni_detach;
+ gboolean jni_detach = FALSE;
jstring jsql;
jenv = _gda_jdbc_get_jenv (&jni_detach, error);
diff --git a/providers/oracle/gda-oracle-util.c b/providers/oracle/gda-oracle-util.c
index edf4ffa..57cfb67 100644
--- a/providers/oracle/gda-oracle-util.c
+++ b/providers/oracle/gda-oracle-util.c
@@ -44,7 +44,7 @@ _gda_oracle_make_error (GdaConnection *cnc, dvoid *hndlp, ub4 type, const gchar
{
GdaConnectionEvent *error = NULL;
gchar errbuf[512];
- ub4 errcode;
+ ub4 errcode = GDA_CONNECTION_EVENT_CODE_UNKNOWN;
gchar *source;
if (hndlp != NULL) {
diff --git a/providers/reuseable/postgres/gda-postgres-meta.c b/providers/reuseable/postgres/gda-postgres-meta.c
index 93ee001..3681dfe 100644
--- a/providers/reuseable/postgres/gda-postgres-meta.c
+++ b/providers/reuseable/postgres/gda-postgres-meta.c
@@ -728,7 +728,7 @@ _gda_postgres_meta_el_types (G_GNUC_UNUSED GdaServerProvider *prov, GdaConnectio
const GValue *specific_name)
{
const gchar *cstr;
- GdaDataModel *model;
+ GdaDataModel *model = NULL;
gboolean retval;
GdaPostgresReuseable *rdata;
diff --git a/testing/gda-provider-status.c b/testing/gda-provider-status.c
index 169ec57..4606fb0 100644
--- a/testing/gda-provider-status.c
+++ b/testing/gda-provider-status.c
@@ -106,7 +106,7 @@ main (int argc, char *argv[])
cvalue = gda_data_model_get_value_at (providers, 0, i, &error);
if (!cvalue)
- g_error ("Can't load the '%s' provider: %s\n", pname,
+ g_error ("Can't load next provider: %s\n",
error && error->message ? error->message : "No detail");
pname = g_value_get_string (cvalue);
prov = gda_config_get_provider (pname, &error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]