[Xfce4-commits] <squeeze:peter/libsqueeze> Solved some invalid memory accesses
Peter de Ridder
noreply at xfce.org
Sun Feb 3 21:46:03 CET 2013
Updating branch refs/heads/peter/libsqueeze
to cb2820bac787558ef5c81c18f1c1a7e14a2f58ab (commit)
from c377a7b361708fc4e6ad4489dba4dc76e9a90025 (commit)
commit cb2820bac787558ef5c81c18f1c1a7e14a2f58ab
Author: Peter de Ridder <peter at xfce.org>
Date: Sun Mar 11 18:18:03 2012 +0100
Solved some invalid memory accesses
libsqueeze/archive.c | 2 +-
libsqueeze/datetime.c | 13 ++++++++-----
libsqueeze/datetime.h | 4 ++--
libsqueeze/libsqueeze.c | 3 +++
libsqueeze/support-app.c | 5 +++++
libsqueeze/support-info.c | 9 +++++++--
libsqueeze/support-info.h | 4 ++++
libsqueeze/support-reader.c | 2 +-
8 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/libsqueeze/archive.c b/libsqueeze/archive.c
index 3e343d3..fb2c876 100644
--- a/libsqueeze/archive.c
+++ b/libsqueeze/archive.c
@@ -507,7 +507,7 @@ lsq_archive_operate (
case LSQ_COMMAND_TYPE_REFRESH:
lsq_archive_set_refresh_app( archive, app );
app = archive->priv->refresh_app;
- if ( NULL != app->refresh_cmd_queue )
+ if ( NULL != app && NULL != app->refresh_cmd_queue )
{
ctx = lsq_command_queue_execute( app->refresh_cmd_queue, archive, NULL, NULL, app->file->parser, error );
}
diff --git a/libsqueeze/datetime.c b/libsqueeze/datetime.c
index c26403d..4c6336a 100644
--- a/libsqueeze/datetime.c
+++ b/libsqueeze/datetime.c
@@ -118,7 +118,7 @@ value_datetime_to_string (
}
}
-GType
+static GType
lsq_datetime_get_type ( void )
{
static GType type = G_TYPE_INVALID;
@@ -167,13 +167,16 @@ lsq_datetime_get_type ( void )
return type;
}
+GType
+lsq_datetime_get_type_const ( void )
+{
+ return lsq_datetime_get_type();
+}
+
void
lsq_datetime_register_type ( void )
{
- /* Force lsq_datetime_get_type to get called, and not optimized by G_GNUC_CONST */
- volatile GType type;
- type = lsq_datetime_get_type();
- type;
+ lsq_datetime_get_type();
}
LSQDateTime
diff --git a/libsqueeze/datetime.h b/libsqueeze/datetime.h
index 05e1000..8f3495a 100644
--- a/libsqueeze/datetime.h
+++ b/libsqueeze/datetime.h
@@ -19,7 +19,7 @@
G_BEGIN_DECLS
-#define LSQ_TYPE_DATETIME lsq_datetime_get_type()
+#define LSQ_TYPE_DATETIME lsq_datetime_get_type_const()
#define LSQ_DATETIME(v) ((LSQDateTime)(v))
#define LSQ_DATETIME_NULL (LSQ_DATETIME(0))
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
typedef gint64 LSQDateTime;
GType
-lsq_datetime_get_type ( void ) G_GNUC_CONST;
+lsq_datetime_get_type_const ( void ) G_GNUC_CONST;
void
lsq_datetime_register_type ( void );
diff --git a/libsqueeze/libsqueeze.c b/libsqueeze/libsqueeze.c
index 1c8316b..65a40b7 100644
--- a/libsqueeze/libsqueeze.c
+++ b/libsqueeze/libsqueeze.c
@@ -28,6 +28,7 @@
#include "internals.h"
#include "support-reader.h"
#include "support-file.h"
+#include "support-info.h"
#include "archive.h"
#include "libsqueeze.h"
@@ -93,6 +94,8 @@ lsq_init ( void )
lsq_support_file_table = g_hash_table_new( g_str_hash, g_str_equal );
+ lsq_init_support_info();
+
#ifndef NO_XDG_DATA_DIRS
data_squeeze = g_build_filename( user_dir, "squeeze", NULL );
lsq_read_squeeze_dir( data_squeeze );
diff --git a/libsqueeze/support-app.c b/libsqueeze/support-app.c
index d40e082..f29b44a 100644
--- a/libsqueeze/support-app.c
+++ b/libsqueeze/support-app.c
@@ -69,6 +69,8 @@ lsq_support_app_new ( LSQSupportFile *file )
const gchar *
lsq_support_app_get_id ( const LSQSupportApp *app )
{
+ g_return_val_if_fail( LSQ_IS_SUPPORT_APP( app ), NULL );
+
return app->id;
}
@@ -78,6 +80,9 @@ lsq_support_app_compare_id (
const gchar *id
)
{
+ g_return_val_if_fail( LSQ_IS_SUPPORT_APP( app ), -1 );
+ g_return_val_if_fail( NULL != id, 1 );
+
return strcmp( app->id, id );
}
diff --git a/libsqueeze/support-info.c b/libsqueeze/support-info.c
index 50fc63c..3e3cf33 100644
--- a/libsqueeze/support-info.c
+++ b/libsqueeze/support-info.c
@@ -48,12 +48,17 @@ struct _LSQSupportInfoClass
G_DEFINE_TYPE ( LSQSupportInfo, lsq_support_info, G_TYPE_OBJECT );
-GHashTable *lsq_support_info_table;
+GHashTable *lsq_support_info_table = NULL;
+
+void
+lsq_init_support_info ( void )
+{
+ lsq_support_info_table = g_hash_table_new( g_str_hash, g_str_equal );
+}
static void
lsq_support_info_class_init ( LSQSupportInfoClass *klass )
{
- lsq_support_info_table = g_hash_table_new( g_str_hash, g_str_equal );
}
static void
diff --git a/libsqueeze/support-info.h b/libsqueeze/support-info.h
index ac8a25a..7db702f 100644
--- a/libsqueeze/support-info.h
+++ b/libsqueeze/support-info.h
@@ -24,6 +24,10 @@ G_BEGIN_DECLS
typedef struct _LSQSupportInfoClass LSQSupportInfoClass;
+void
+lsq_init_support_info ( void );
+
+
LSQSupportInfo *
lsq_support_info_new ( const gchar *contentype );
diff --git a/libsqueeze/support-reader.c b/libsqueeze/support-reader.c
index 13adf99..68fc502 100644
--- a/libsqueeze/support-reader.c
+++ b/libsqueeze/support-reader.c
@@ -517,7 +517,7 @@ lsq_support_reader_parse_file (
}
xfce_rc_close( rc );
- g_strfreev( mime_type );
+ g_strfreev( mime_types );
return support_file;
}
More information about the Xfce4-commits
mailing list