Commit 47afc752 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

removed redundant check that is already performed by

2008-08-25  Sven Neumann  <sven@gimp.org>

	* app/base/tile-manager.c (read_pixel_data_1): removed redundant
	check that is already performed by tile_manager_get_tile_num().
	Warn if an out-of-bounds read is requested, instead of silently
	doing nothing.



svn path=/trunk/; revision=26755
parent afcd02f7
2008-08-25 Sven Neumann <sven@gimp.org>
* app/base/tile-manager.c (read_pixel_data_1): removed redundant
check that is already performed by tile_manager_get_tile_num().
Warn if an out-of-bounds read is requested, instead of silently
doing nothing.
2008-08-25 Sven Neumann <sven@gimp.org>
* app/dialogs/image-scale-dialog.c: hide the Scale dialog before
......
......@@ -755,50 +755,48 @@ read_pixel_data_1 (TileManager *tm,
gint y,
guchar *buffer)
{
if (x >= 0 && y >= 0 && x < tm->width && y < tm->height)
{
gint num = tile_manager_get_tile_num (tm, x, y);
const gint num = tile_manager_get_tile_num (tm, x, y);
if (num != tm->cached_num) /* must fetch a new tile */
{
Tile *tile;
g_return_if_fail (num >= 0);
if (tm->cached_tile)
tile_release (tm->cached_tile, FALSE);
if (num != tm->cached_num) /* must fetch a new tile */
{
Tile *tile;
tm->cached_num = -1;
tm->cached_tile = NULL;
if (tm->cached_tile)
tile_release (tm->cached_tile, FALSE);
/* use a temporary variable instead of assigning to
* tm->cached_tile directly to make sure tm->cached_num
* and tm->cached_tile are always in a consistent state.
* (the requested tile might be invalid and needs to be
* validated, which would call tile_manager_get() recursively,
* which in turn would clear the cached tile) See bug #472770.
*/
tile = tile_manager_get (tm, num, TRUE, FALSE);
tm->cached_num = -1;
tm->cached_tile = NULL;
tm->cached_num = num;
tm->cached_tile = tile;
}
/* use a temporary variable instead of assigning to
* tm->cached_tile directly to make sure tm->cached_num
* and tm->cached_tile are always in a consistent state.
* (the requested tile might be invalid and needs to be
* validated, which would call tile_manager_get() recursively,
* which in turn would clear the cached tile) See bug #472770.
*/
tile = tile_manager_get (tm, num, TRUE, FALSE);
if (tm->cached_tile)
{
const guchar *src = tile_data_pointer (tm->cached_tile, x, y);
switch (tm->bpp)
{
case 4:
*buffer++ = *src++;
case 3:
*buffer++ = *src++;
case 2:
*buffer++ = *src++;
case 1:
*buffer++ = *src++;
}
}
tm->cached_num = num;
tm->cached_tile = tile;
}
{
const guchar *src = tile_data_pointer (tm->cached_tile, x, y);
switch (tm->bpp)
{
case 4:
*buffer++ = *src++;
case 3:
*buffer++ = *src++;
case 2:
*buffer++ = *src++;
case 1:
*buffer++ = *src++;
}
}
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment