Bug 632568 - 'gimp-drawable-transform-rotate-simple' makes GIMP crash in some cases

Applied modified patch from Massimo that makes sure we don't use
negative width/height if source and dest regions don't overlap.
This commit is contained in:
Michael Natterer 2011-03-18 00:51:05 +01:00
parent 94fa7a0471
commit 1c8149a553
2 changed files with 58 additions and 4 deletions

View File

@ -455,10 +455,15 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
orig_height = clip_width;
break;
}
}
new_width = clip_width;
new_height = clip_height;
new_width = clip_width;
new_height = clip_height;
}
else
{
new_width = 0;
new_height = 0;
}
}
else
{
@ -472,7 +477,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable *drawable,
new_y = 0;
}
if (new_width == 0 && new_height == 0)
if (new_width < 1 || new_height < 1)
return new_tiles;
pixel_region_init (&srcPR, orig_tiles,

View File

@ -23,6 +23,7 @@
#include "widgets/gimpuimanager.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
@ -96,6 +97,49 @@ gimp_test_image_teardown (GimpTestFixture *fixture,
g_object_unref (fixture->image);
}
/**
* rotate_non_overlapping:
* @fixture:
* @data:
*
* Super basic test that makes sure we can add a layer
* and call gimp_item_rotate with center at (0, -10)
* without triggering a failed assertion .
**/
static void
rotate_non_overlapping (GimpTestFixture *fixture,
gconstpointer data)
{
GimpImage *image = fixture->image;
GimpLayer *layer;
GimpContext *context = gimp_context_new (gimp, "Test", NULL /*template*/);
gboolean result;
g_assert_cmpint (gimp_image_get_n_layers (image), ==, 0);
layer = gimp_layer_new (image,
GIMP_TEST_IMAGE_SIZE,
GIMP_TEST_IMAGE_SIZE,
GIMP_RGBA_IMAGE,
"Test Layer",
1.0,
GIMP_NORMAL_MODE);
g_assert_cmpint (GIMP_IS_LAYER (layer), ==, TRUE);
result = gimp_image_add_layer (image,
layer,
GIMP_IMAGE_ACTIVE_PARENT,
0,
FALSE);
gimp_item_rotate (GIMP_ITEM (layer), context, GIMP_ROTATE_90, 0., -10., TRUE);
g_assert_cmpint (result, ==, TRUE);
g_assert_cmpint (gimp_image_get_n_layers (image), ==, 1);
g_object_unref (context);
}
/**
* add_layer:
* @fixture:
@ -196,10 +240,15 @@ main (int argc,
/* Add tests */
ADD_IMAGE_TEST (add_layer);
ADD_IMAGE_TEST (remove_layer);
ADD_IMAGE_TEST (rotate_non_overlapping);
/* Run the tests */
result = g_test_run ();
/* Don't write files to the source dir */
gimp_test_utils_set_gimp2_directory ("GIMP_TESTING_ABS_TOP_BUILDDIR",
"app/tests/gimpdir-output");
/* Exit so we don't break script-fu plug-in wire */
gimp_exit (gimp, TRUE);