[gimp] app: Fix potential segfault caused by accessing empty history buffer



commit d9932ff159d67d9aeecbe3430ac3bd3872bf14c2
Author: Alexia Death <alexiadeath gmail com>
Date:   Thu Sep 9 21:56:19 2010 +0300

    app: Fix potential segfault caused by accessing empty history buffer

 app/display/gimpdisplayshell-coords.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-coords.c b/app/display/gimpdisplayshell-coords.c
index 567a9d0..c92e784 100644
--- a/app/display/gimpdisplayshell-coords.c
+++ b/app/display/gimpdisplayshell-coords.c
@@ -163,7 +163,9 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
           coords->velocity = MIN (coords->velocity, 1.0);
         }
 
-      if ((fabs (delta_x) > DIRECTION_RADIUS) && (fabs (delta_y) > DIRECTION_RADIUS))
+      if (((fabs (delta_x) > DIRECTION_RADIUS) &&
+           (fabs (delta_y) > DIRECTION_RADIUS)) ||
+          (shell->event_history->len < 4))
         {
           dir_delta_x = delta_x;
           dir_delta_y = delta_y;
@@ -173,7 +175,8 @@ gimp_display_shell_eval_event (GimpDisplayShell *shell,
           gint x = 3;
 
           while (((fabs (dir_delta_x) < DIRECTION_RADIUS) ||
-                  (fabs (dir_delta_y) < DIRECTION_RADIUS)) && (x >= 0))
+                  (fabs (dir_delta_y) < DIRECTION_RADIUS)) &&
+                  (x >= 0))
             {
               const GimpCoords old_event = g_array_index (shell->event_history,
                                                           GimpCoords, x);



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