move check for event.xbutton.button <= GLUT_MAX_MENUS (see sf bug 1484284)
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 10 May 2006 19:21:39 +0000 (19:21 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 10 May 2006 19:21:39 +0000 (19:21 +0000)
src/glut/glx/glut_event.c

index f997f772c70c8c8171bc5e5dc8b3785e7f93342c..4e67da674ed2d99cda18b70d659a135268b0d479 100644 (file)
@@ -439,11 +439,15 @@ processEventsAndTimeouts(void)
         } else {
           window = __glutGetWindow(event.xbutton.window);
           /* added button check for mice with > 3 buttons */
-          if (window && event.xbutton.button <= GLUT_MAX_MENUS) {
+          if (window) {
             GLUTmenu *menu;
            int menuNum;
 
-            menuNum = window->menu[event.xbutton.button - 1];
+            if (event.xbutton.button <= GLUT_MAX_MENUS)
+              menuNum = window->menu[event.xbutton.button - 1];
+            else
+              menuNum = 0;
+
             /* Make sure that __glutGetMenuByNum is only called if there
               really is a menu present. */
             if ((menuNum > 0) && (menu = __glutGetMenuByNum(menuNum))) {