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



commit 167ef42c5c165c0669ab09ae5513eae9dd5b93ee
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 a68389e..5747c4d 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -1241,12 +1241,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 &&
@@ -1308,10 +1309,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));
@@ -1855,11 +1858,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)
@@ -1933,10 +1938,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]