Commit a72b704e authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

check boundary conditions before pushing a pixel to the queue.

2005-08-08  Sven Neumann  <sven@gimp.org>

	* app/base/siox.c (find_max_blob): check boundary conditions
	before pushing a pixel to the queue.
parent a8257d8d
2005-08-08 Sven Neumann <sven@gimp.org>
* app/base/siox.c (find_max_blob): check boundary conditions
before pushing a pixel to the queue.
2005-08-08 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdataeditor.c: made hitting Escape in the name
......
......@@ -630,31 +630,45 @@ find_max_blob (TileManager *mask,
{
gint regioncount = 0;
if (labelfield[i] == 0 && *d > 127)
if (labelfield[i] == 0 && (*d & 0x80))
g_queue_push_tail (q, GINT_TO_POINTER (i));
while (! g_queue_is_empty (q))
{
gint pos = GPOINTER_TO_INT (g_queue_pop_head (q));
if (pos < 0 || pos >= length)
continue;
if (G_UNLIKELY (pos < 0 || pos >= length))
{
g_warning ("%s: should never get here", G_STRLOC);
continue;
}
if (labelfield[pos] == 0)
{
guchar val;
gint x = pos % width;
gint y = pos / width;
read_pixel_data_1 (mask, x, y , &val);
read_pixel_data_1 (mask, pos % width, pos / width, &val);
if (val > 127)
if (val & 0x80)
{
labelfield[pos] = curlabel;
regioncount++;
g_queue_push_tail (q, GINT_TO_POINTER (pos + 1));
g_queue_push_tail (q, GINT_TO_POINTER (pos - 1));
g_queue_push_tail (q, GINT_TO_POINTER (pos + width));
g_queue_push_tail (q, GINT_TO_POINTER (pos - width));
if (x + 1 < width)
g_queue_push_tail (q,
GINT_TO_POINTER (pos + 1));
if (x > 0)
g_queue_push_tail (q,
GINT_TO_POINTER (pos - 1));
if (y + 1 < height)
g_queue_push_tail (q,
GINT_TO_POINTER (pos + width));
if (y > 0)
g_queue_push_tail (q,
GINT_TO_POINTER (pos - width));
}
}
}
......
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