[gegl/soc-2013-n-point-deformation: 14/22] operations: npd: add proper boundary check for get/set pixel functions
- From: Marek Dvoroznak <dvoromar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/soc-2013-n-point-deformation: 14/22] operations: npd: add proper boundary check for get/set pixel functions
- Date: Sat, 5 Oct 2013 01:25:11 +0000 (UTC)
commit e64c7ba439a4d615e48e961b28805f4e43fa6c67
Author: Marek Dvoroznak <dvoromar gmail com>
Date: Thu Aug 15 01:14:36 2013 +0200
operations: npd: add proper boundary check for get/set pixel functions
operations/external/npd.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/operations/external/npd.c b/operations/external/npd.c
index 68f12fa..d8df11c 100644
--- a/operations/external/npd.c
+++ b/operations/external/npd.c
@@ -92,11 +92,11 @@ void npd_set_pixel_color_impl (NPDImage *image,
gint y,
NPDColor *color)
{
- gint position = 4 * (y * image->width + x);
- gint max = 4 * image->width * image->height;
-
- if (position > 0 && position < max)
+ if (x > -1 && x < image->width &&
+ y > -1 && y < image->height)
{
+ gint position = 4 * (y * image->width + x);
+
image->buffer[position + 0] = color->r;
image->buffer[position + 1] = color->g;
image->buffer[position + 2] = color->b;
@@ -110,11 +110,11 @@ npd_get_pixel_color_impl (NPDImage *image,
gint y,
NPDColor *color)
{
- gint position = 4 * (y * image->width + x);
- gint max = 4 * image->width * image->height;
-
- if (position > 0 && position < max)
+ if (x > -1 && x < image->width &&
+ y > -1 && y < image->height)
{
+ gint position = 4 * (y * image->width + x);
+
color->r = image->buffer[position + 0];
color->g = image->buffer[position + 1];
color->b = image->buffer[position + 2];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]