Fix access beyond array bounds
authorRicardo Mones <ricardo@mones.org>
Fri, 2 Aug 2013 08:00:34 +0000 (10:00 +0200)
committerRicardo Mones <ricardo@mones.org>
Fri, 2 Aug 2013 08:00:34 +0000 (10:00 +0200)
Which shouldn't happen, but keeps the compiler happy...

src/toolbar.c
src/toolbar.h

index 690073a..5259f41 100644 (file)
@@ -242,7 +242,7 @@ struct {
 struct {
        const gchar  *conf_file;
        GSList       *item_list;
-} toolbar_config[3] = {
+} toolbar_config[NUM_TOOLBARS] = {
        { "toolbar_main.xml",    NULL},
        { "toolbar_compose.xml", NULL}, 
        { "toolbar_msgview.xml", NULL}
@@ -767,7 +767,7 @@ void toolbar_read_config_file(ToolbarType source)
                else if (source == TOOLBAR_MSGVIEW) 
                        toolbar_set_default(TOOLBAR_MSGVIEW);
                else {          
-                       g_warning("failed to write Toolbar Configuration to %s\n", toolbar_config[source].conf_file);
+                       g_warning("refusing to write unknown Toolbar Configuration number %d\n", source);
                        return;
                }
 
index f0cd8c8..7eebad2 100644 (file)
@@ -34,6 +34,8 @@ typedef enum {
        TOOLBAR_MSGVIEW
 } ToolbarType;
 
+#define NUM_TOOLBARS   3
+
 typedef enum 
 {
        COMPOSEBUTTON_MAIL,