[gimp] Bug 689750 - Crash on shrinking a selection by an invalid value



commit 571f5c86b3b12d4637849a702c2c921c9b2970ef
Author: Michael Natterer <mitch gimp org>
Date:   Thu Nov 17 12:50:59 2016 +0100

    Bug 689750 - Crash on shrinking a selection by an invalid value
    
    Limit selection shrinking to MIN (sel_width, sel_height) / 2, larger
    values make no sense.
    
    Limit selection bordering to the same value and growing to
    MAX (image_width, image_height).

 app/actions/select-commands.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index cbbdc1f..b24de84 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -201,9 +201,16 @@ select_shrink_cmd_callback (GtkAction *action,
     {
       GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
       GtkWidget        *button;
+      gint              width;
+      gint              height;
+      gint              max_value;
       gdouble           xres;
       gdouble           yres;
 
+      gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
+                        NULL, NULL, &width, &height);
+      max_value = MIN (width, height) / 2;
+
       gimp_image_get_resolution (image, &xres, &yres);
 
       dialog = gimp_query_size_box (_("Shrink Selection"),
@@ -211,7 +218,8 @@ select_shrink_cmd_callback (GtkAction *action,
                                     gimp_standard_help_func,
                                     GIMP_HELP_SELECTION_SHRINK,
                                     _("Shrink selection by"),
-                                    config->selection_shrink_radius, 1, 32767, 0,
+                                    config->selection_shrink_radius,
+                                    1, max_value, 0,
                                     gimp_display_get_shell (display)->unit,
                                     MIN (xres, yres),
                                     FALSE,
@@ -255,9 +263,16 @@ select_grow_cmd_callback (GtkAction *action,
   if (! dialog)
     {
       GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+      gint              width;
+      gint              height;
+      gint              max_value;
       gdouble           xres;
       gdouble           yres;
 
+      width  = gimp_image_get_width  (image);
+      height = gimp_image_get_height (image);
+      max_value = MAX (width, height);
+
       gimp_image_get_resolution (image, &xres, &yres);
 
       dialog = gimp_query_size_box (_("Grow Selection"),
@@ -265,7 +280,8 @@ select_grow_cmd_callback (GtkAction *action,
                                     gimp_standard_help_func,
                                     GIMP_HELP_SELECTION_GROW,
                                     _("Grow selection by"),
-                                    config->selection_grow_radius, 1, 32767, 0,
+                                    config->selection_grow_radius,
+                                    1, max_value, 0,
                                     gimp_display_get_shell (display)->unit,
                                     MIN (xres, yres),
                                     FALSE,
@@ -298,9 +314,16 @@ select_border_cmd_callback (GtkAction *action,
       GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
       GtkWidget        *combo;
       GtkWidget        *button;
+      gint              width;
+      gint              height;
+      gint              max_value;
       gdouble           xres;
       gdouble           yres;
 
+      gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
+                        NULL, NULL, &width, &height);
+      max_value = MIN (width, height) / 2;
+
       gimp_image_get_resolution (image, &xres, &yres);
 
       dialog = gimp_query_size_box (_("Border Selection"),
@@ -308,7 +331,8 @@ select_border_cmd_callback (GtkAction *action,
                                     gimp_standard_help_func,
                                     GIMP_HELP_SELECTION_BORDER,
                                     _("Border selection by"),
-                                    config->selection_border_radius, 1, 32767, 0,
+                                    config->selection_border_radius,
+                                    1, max_value, 0,
                                     gimp_display_get_shell (display)->unit,
                                     MIN (xres, yres),
                                     FALSE,


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