[gegl] buffer: fix single-pixel gegl_buffer_get()
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: fix single-pixel gegl_buffer_get()
- Date: Thu, 15 Mar 2018 09:23:33 +0000 (UTC)
commit 9102b31f5152d18861f1a4feacb45a4b94163cda
Author: Ell <ell_se yahoo com>
Date: Thu Mar 15 05:10:02 2018 -0400
buffer: fix single-pixel gegl_buffer_get()
In _gegl_buffer_get_unlocked(), move the assignment of the buffer's
format to the 'format' parameter, in case it's NULL, to the
beginning of the function. In particular, move it before the call
to gegl_buffer_get_pixel(), which can segfault if called with a
NULL format.
gegl/buffer/gegl-buffer-access.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 52fc23c..bb2d0eb 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -150,7 +150,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
gint px_size = babl_format_get_bytes_per_pixel (buffer->soft_format);
guchar *tp = gegl_tile_get_data (tile) + (offsety * tile_width + offsetx) * px_size;
- if (format && format != buffer->soft_format)
+ if (format != buffer->soft_format)
{
babl_process (babl_fish (buffer->soft_format, format), tp, buf, 1);
}
@@ -1995,12 +1995,16 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
{
GeglAbyssPolicy repeat_mode = flags & 0x7; /* mask off interpolation from repeat mode part of flags */
+ g_return_if_fail (scale > 0.0f);
+
+ if (format == NULL)
+ format = buffer->soft_format;
+
if (gegl_cl_is_accelerated ())
{
gegl_buffer_cl_cache_flush (buffer, rect);
}
-
if (scale == 1.0 &&
rect &&
rect->width == 1)
@@ -2012,9 +2016,6 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
}
else
{
- if (format == NULL)
- format = buffer->soft_format;
-
if (buffer->soft_format == format ||
rowstride != babl_format_get_bytes_per_pixel (format))
{
@@ -2036,11 +2037,6 @@ _gegl_buffer_get_unlocked (GeglBuffer *buffer,
return;
}
- g_return_if_fail (scale > 0.0f);
-
- if (format == NULL)
- format = buffer->soft_format;
-
if (!rect && GEGL_FLOAT_EQUAL (scale, 1.0))
{
gegl_buffer_iterate_read_dispatch (buffer, &buffer->extent, dest_buf,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]