[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47448] trunk/blender/source/blender/ blenkernel/intern/mask.c: fix for possible uninitialized pointer use in mask rasterize and remove some dead code .

Campbell Barton ideasman42 at gmail.com
Tue Jun 5 08:54:35 CEST 2012


Revision: 47448
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47448
Author:   campbellbarton
Date:     2012-06-05 06:54:18 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
fix for possible uninitialized pointer use in mask rasterize and remove some dead code.

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

Modified: trunk/blender/source/blender/blenkernel/intern/mask.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mask.c	2012-06-05 06:18:31 UTC (rev 47447)
+++ trunk/blender/source/blender/blenkernel/intern/mask.c	2012-06-05 06:54:18 UTC (rev 47448)
@@ -1972,16 +1972,7 @@
 	/* temp blending buffer */
 	const int buffer_size = width * height;
 	float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__);
-	float max_dseg_len = 0.0f;
 
-	if (width >= height) {
-		max_dseg_len = (float)(width);
-	}
-	else {
-		max_dseg_len = (float)(height);
-	}
-	max_dseg_len = 1.0f / max_dseg_len;
-
 	for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
 		MaskSpline *spline;
 		float alpha;
@@ -1999,51 +1990,56 @@
 			float (*diff_feather_points)[2];
 			int tot_diff_feather_points;
 
-			diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height, &tot_diff_point);
+			diff_points = BKE_mask_spline_differentiate_with_resolution(spline, width, height,
+			                                                            &tot_diff_point);
+
 			if (tot_diff_point) {
 				diff_feather_points =
 				        BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height,
 				                                                                      &tot_diff_feather_points);
-			}
 
-			/* TODO, make this optional! */
-			if (width != height) {
-				float *fp;
-				float *ffp;
-				int i;
-				float asp;
+				/* TODO, make this optional! */
+				if (width != height) {
+					float *fp;
+					float *ffp;
+					int i;
+					float asp;
 
-				if (width < height) {
-					fp = &diff_points[0][0];
-					ffp = &diff_feather_points[0][0];
-					asp = (float)width / (float)height;
-				}
-				else {
-					fp = &diff_points[0][1];
-					ffp = &diff_feather_points[0][1];
-					asp = (float)height / (float)width;
-				}
+					if (width < height) {
+						fp = &diff_points[0][0];
+						ffp = tot_diff_feather_points ? &diff_feather_points[0][0] : NULL;
+						asp = (float)width / (float)height;
+					}
+					else {
+						fp = &diff_points[0][1];
+						ffp = tot_diff_feather_points ? &diff_feather_points[0][1] : NULL;
+						asp = (float)height / (float)width;
+					}
 
-				for (i = 0; i < tot_diff_point; i++, fp += 2) {
-					(*fp) = (((*fp) - 0.5f) / asp) + 0.5f;
+					for (i = 0; i < tot_diff_point; i++, fp += 2) {
+						(*fp) = (((*fp) - 0.5f) / asp) + 0.5f;
+					}
+
+					if (tot_diff_feather_points) {
+						for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) {
+							(*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f;
+						}
+					}
 				}
-				for (i = 0; i < tot_diff_feather_points; i++, ffp += 2) {
-					(*ffp) = (((*ffp) - 0.5f) / asp) + 0.5f;
-				}
-			}
 
-			if (tot_diff_point) {
-				PLX_raskterize((float (*)[2])diff_points, tot_diff_point,
-				               buffer_tmp, width, height);
+				if (tot_diff_point) {
+					PLX_raskterize(diff_points, tot_diff_point,
+					               buffer_tmp, width, height);
 
-				if (tot_diff_feather_points) {
-					PLX_raskterize_feather((float (*)[2])diff_points, tot_diff_point,
-					                       (float (*)[2])diff_feather_points, tot_diff_feather_points,
-					                       buffer_tmp, width, height);
-					MEM_freeN(diff_feather_points);
-				}
+					if (tot_diff_feather_points) {
+						PLX_raskterize_feather(diff_points, tot_diff_point,
+						                       diff_feather_points, tot_diff_feather_points,
+						                       buffer_tmp, width, height);
+						MEM_freeN(diff_feather_points);
+					}
 
-				MEM_freeN(diff_points);
+					MEM_freeN(diff_points);
+				}
 			}
 		}
 




More information about the Bf-blender-cvs mailing list