gimp r25670 - in trunk: . app/core



Author: neo
Date: Wed May 14 16:19:33 2008
New Revision: 25670
URL: http://svn.gnome.org/viewvc/gimp?rev=25670&view=rev

Log:
2008-05-14  Sven Neumann  <sven gimp org>

	* app/core/gimpcurve.c (gimp_curve_plot): don't write over the end
	of the samples array.  Someone should review this code. It looks
	as if the loop could be rewritten in a safer and cleaner way.


Modified:
   trunk/ChangeLog
   trunk/app/core/gimpcurve.c

Modified: trunk/app/core/gimpcurve.c
==============================================================================
--- trunk/app/core/gimpcurve.c	(original)
+++ trunk/app/core/gimpcurve.c	Wed May 14 16:19:33 2008
@@ -161,7 +161,11 @@
 static void
 gimp_curve_init (GimpCurve *curve)
 {
-  curve->identity = FALSE;
+  curve->n_points  = 0;
+  curve->points    = NULL;
+  curve->n_samples = 0;
+  curve->samples   = NULL;
+  curve->identity  = FALSE;
 }
 
 static void
@@ -881,8 +885,9 @@
           3 * y2 * (1-t) * t     * t     +
               y3 * t     * t     * t;
 
-      index = ROUND (x0 * (gdouble) (curve->n_samples - 1)) + i;
+      index = i + ROUND (x0 * (gdouble) (curve->n_samples - 1));
 
-      curve->samples[index] = CLAMP (y, 0.0, 1.0);
+      if (index < curve->n_samples)
+        curve->samples[index] = CLAMP (y, 0.0, 1.0);
     }
 }



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