From 19e86ee45a776e95d580239a3acb7e2dff28a065 Mon Sep 17 00:00:00 2001
From: Martin Nilsson <mani@lysator.liu.se>
Date: Wed, 13 Aug 2003 09:36:24 +0200
Subject: [PATCH] Don't read outside the image.

Rev: src/modules/Image/matrix.c:1.46
---
 src/modules/Image/matrix.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c
index 763844d1c8..ea55387715 100644
--- a/src/modules/Image/matrix.c
+++ b/src/modules/Image/matrix.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: matrix.c,v 1.45 2003/03/22 16:44:16 grubba Exp $
+|| $Id: matrix.c,v 1.46 2003/08/13 07:36:24 nilsson Exp $
 */
 
 /*
@@ -270,8 +270,8 @@ void img_scale2(struct image *dest, struct image *source)
    dest->img=new;
    dest->xsize=newx;
    dest->ysize=newy;
-   for (y = 0; y < newy; y++)
-      for (x = 0; x < newx; x++) 
+   for (y = 0; y < newy-1; y++)
+      for (x = 0; x < newx-1; x++)
       {
 	 pixel(dest,x,y).r = (COLORTYPE)
 	    (((INT32) pixel(source,2*x+0,2*y+0).r+
@@ -289,6 +289,10 @@ void img_scale2(struct image *dest, struct image *source)
 	      (INT32) pixel(source,2*x+0,2*y+1).b+
 	      (INT32) pixel(source,2*x+1,2*y+1).b) >> 2);
       }
+   for (y = 0; y < newy; y++)
+     pixel(dest,newx-1,y) = pixel(source,2*(newx-1),2*y);
+   for (x = 0; x < newx; x++)
+     pixel(dest,x,newy-1) = pixel(source,2*x,2*(newy-1));
    THREADS_DISALLOW();
 }
 
-- 
GitLab