[mutter] prefs: Initialize button_layout struct even on pref string corner cases



commit 779ef582f140bab2eb4bcc53af0e27824004a6da
Author: Rui Matos <tiagomatos gmail com>
Date:   Sat Jul 23 22:58:06 2011 +0100

    prefs: Initialize button_layout struct even on pref string corner cases
    
    We were leaving some members of the button_layout struct uninitialized if the
    pref string didn't have at least one colon or if it was an empty string ("").
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654539

 src/core/prefs.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 73d2fc3..2faf130 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -1679,6 +1679,7 @@ button_layout_handler (MetaPreference pref,
   if (string_value)
     sides = g_strsplit (string_value, ":", 2);
 
+  i = 0;
   if (sides != NULL && sides[0] != NULL)
     {
       char **buttons;
@@ -1733,12 +1734,13 @@ button_layout_handler (MetaPreference pref,
           ++b;
         }
 
-      new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
-      new_layout.left_buttons_has_spacer[i] = FALSE;
-      
       g_strfreev (buttons);
     }
 
+  new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
+  new_layout.left_buttons_has_spacer[i] = FALSE;
+
+  i = 0;
   if (sides != NULL && sides[0] != NULL && sides[1] != NULL)
     {
       char **buttons;
@@ -1792,12 +1794,12 @@ button_layout_handler (MetaPreference pref,
           ++b;
         }
 
-      new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
-      new_layout.right_buttons_has_spacer[i] = FALSE;
-      
       g_strfreev (buttons);
     }
 
+  new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
+  new_layout.right_buttons_has_spacer[i] = FALSE;
+
   g_strfreev (sides);
   
   /* Invert the button layout for RTL languages */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]