[gtk+/gtk-3-20] menushell: Don’t dereference before typechecking



commit ea74712de8c6149a91ad4712ccaaca7a03ec0c53
Author: Daniel Boles <dboles src gnome org>
Date:   Fri Jan 20 22:15:42 2017 +0000

    menushell: Don’t dereference before typechecking

 gtk/gtkmenushell.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 4eb22ef..84150fe 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -1238,12 +1238,13 @@ void
 gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
                             GtkWidget    *menu_item)
 {
-  GtkMenuShellPrivate *priv = menu_shell->priv;
+  GtkMenuShellPrivate *priv;
   GtkMenuShellClass *class;
 
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
   g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
 
+  priv = menu_shell->priv;
   class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
 
   if (class->select_item &&
@@ -1305,10 +1306,12 @@ gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
 void
 gtk_menu_shell_deselect (GtkMenuShell *menu_shell)
 {
-  GtkMenuShellPrivate *priv = menu_shell->priv;
+  GtkMenuShellPrivate *priv;
 
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
 
+  priv = menu_shell->priv;
+
   if (priv->active_menu_item)
     {
       gtk_menu_item_deselect (GTK_MENU_ITEM (priv->active_menu_item));
@@ -1852,11 +1855,13 @@ void
 _gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
                                  GdkDevice    *device)
 {
-  GtkMenuShellPrivate *priv = menu_shell->priv;
+  GtkMenuShellPrivate *priv;
 
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
   g_return_if_fail (device == NULL || GDK_IS_DEVICE (device));
 
+  priv = menu_shell->priv;
+
   if (!device)
     priv->grab_pointer = NULL;
   else if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
@@ -1930,10 +1935,12 @@ void
 gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell,
                                gboolean      take_focus)
 {
-  GtkMenuShellPrivate *priv = menu_shell->priv;
+  GtkMenuShellPrivate *priv;
 
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
 
+  priv = menu_shell->priv;
+
   if (priv->take_focus != take_focus)
     {
       priv->take_focus = take_focus;


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