[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56367] trunk/blender/source/blender/ blenkernel/intern/colortools.c: fix for inserting a color-curve point.

Campbell Barton ideasman42 at gmail.com
Sun Apr 28 22:25:25 CEST 2013


Revision: 56367
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56367
Author:   campbellbarton
Date:     2013-04-28 20:25:25 +0000 (Sun, 28 Apr 2013)
Log Message:
-----------
fix for inserting a color-curve point.
- was reading outside memory bounds checking the 'x' point.
- inserting a point to the right of the last point would add a point to the very left instead.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/colortools.c

Modified: trunk/blender/source/blender/blenkernel/intern/colortools.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/colortools.c	2013-04-28 17:44:28 UTC (rev 56366)
+++ trunk/blender/source/blender/blenkernel/intern/colortools.c	2013-04-28 20:25:25 UTC (rev 56367)
@@ -239,23 +239,24 @@
 {
 	CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points");
 	CurveMapPoint *newcmp = NULL;
-	int a, b, foundloc = 0;
-		
+	int a, b;
+	bool foundloc = false;
+
 	/* insert fragments of the old one and the new point to the new curve */
 	cuma->totpoint++;
 	for (a = 0, b = 0; a < cuma->totpoint; a++) {
-		if ((x < cuma->curve[a].x) && !foundloc) {
+		if ((foundloc == false) && ((a + 1 == cuma->totpoint) || (x < cuma->curve[a].x))) {
 			cmp[a].x = x;
 			cmp[a].y = y;
 			cmp[a].flag = CUMA_SELECT;
-			foundloc = 1;
+			foundloc = true;
 			newcmp = &cmp[a];
 		}
 		else {
 			cmp[a].x = cuma->curve[b].x;
 			cmp[a].y = cuma->curve[b].y;
-			cmp[a].flag = cuma->curve[b].flag;
-			cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */
+			/* make sure old points don't remain selected */
+			cmp[a].flag = cuma->curve[b].flag & ~CUMA_SELECT;
 			cmp[a].shorty = cuma->curve[b].shorty;
 			b++;
 		}




More information about the Bf-blender-cvs mailing list