From 8cd676ed4d02b3a1a5ef88aa38258ec307eea864 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 20 Apr 2004 10:17:59 +0000 Subject: [PATCH] check tile != NULL before unrefing it. Fixes bug #140554; merged from 2004-04-20 Sven Neumann * plug-ins/common/iwarp.c (iwarp_get_pixel): check tile != NULL before unrefing it. Fixes bug #140554; merged from stable branch. --- ChangeLog | 5 +++++ plug-ins/common/iwarp.c | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53d6afdd4b..684f4759bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-04-20 Sven Neumann + + * plug-ins/common/iwarp.c (iwarp_get_pixel): check tile != NULL + before unrefing it. Fixes bug #140554; merged from stable branch. + 2004-04-20 Sven Neumann * app/widgets/gimpenumcombobox.c: added more sanity checks. diff --git a/plug-ins/common/iwarp.c b/plug-ins/common/iwarp.c index f575eeb478..6645c509f9 100644 --- a/plug-ins/common/iwarp.c +++ b/plug-ins/common/iwarp.c @@ -229,7 +229,7 @@ static gboolean do_animate_ping_pong = FALSE; static gdouble supersample_threshold_2; static gint xl, yl, xh, yh; static gint tile_width, tile_height; -static GimpTile *tile = NULL; +static GimpTile *tile = NULL; static gdouble pre2img, img2pre; static gint preview_bpp; static gdouble animate_deform_value = 1.0; @@ -345,18 +345,22 @@ iwarp_get_pixel (gint x, { col = x / tile_width; row = y / tile_height; + if (col != old_col || row != old_row) { - gimp_tile_unref (tile, FALSE); + if (tile) + gimp_tile_unref (tile, FALSE); + tile = gimp_drawable_get_tile (drawable, FALSE, row, col); gimp_tile_ref (tile); + old_col = col; old_row = row; } - data = - tile->data + - (tile->ewidth * (y % tile_height) + - x % tile_width) * image_bpp; + + data = tile->data + (tile->ewidth * (y % tile_height) + + x % tile_width) * image_bpp; + for (i = 0; i < image_bpp; i++) *pixel++ = *data++; } @@ -825,7 +829,8 @@ iwarp (void) animate_deform_value = 1.0; iwarp_frame (); } - if (tile != NULL) + + if (tile) { gimp_tile_unref (tile, FALSE); tile = NULL;