[gegl/gsoc2009-gpu] Fix segmentation fault caused by a probable NULL access to the source rect in gegl_gpu_texture_copy(



commit cb3344336c5b36cdfa19ec8d828733d58f5007ce
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date:   Mon Jul 13 14:29:18 2009 +0800

    Fix segmentation fault caused by a probable NULL access to the source rect in gegl_gpu_texture_copy()

 gegl/gpu/gegl-gpu-texture.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gegl/gpu/gegl-gpu-texture.c b/gegl/gpu/gegl-gpu-texture.c
index 3c103d8..2527c7d 100644
--- a/gegl/gpu/gegl-gpu-texture.c
+++ b/gegl/gpu/gegl-gpu-texture.c
@@ -210,6 +210,16 @@ gegl_gpu_texture_copy (const GeglGpuTexture *src,
                        gint                  dest_x,
                        gint                  dest_y)
 {
+  const GeglRectangle *roi;
+
+  if (src_rect == NULL)
+    {
+      GeglRectangle temp = {0, 0, src->width, src->height};
+      roi = &temp;
+    }
+  else
+    roi = src_rect;
+
   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, 
                             GL_COLOR_ATTACHMENT0_EXT, 
                             GL_TEXTURE_RECTANGLE_ARB,
@@ -231,10 +241,10 @@ gegl_gpu_texture_copy (const GeglGpuTexture *src,
                            0,
                            dest_x,
                            dest_y,
-                           src_rect->x,
-                           src_rect->y,
-                           src_rect->width,
-                           src_rect->height);
+                           roi->x,
+                           roi->y,
+                           roi->width,
+                           roi->height);
       glBindTexture       (GL_TEXTURE_RECTANGLE_ARB, 0);
 
       glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]