[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48609] trunk/blender/intern/raskter/ raskter.c: fix for crash with zero area mask.
Campbell Barton
ideasman42 at gmail.com
Wed Jul 4 20:49:09 CEST 2012
Revision: 48609
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48609
Author: campbellbarton
Date: 2012-07-04 18:49:09 +0000 (Wed, 04 Jul 2012)
Log Message:
-----------
fix for crash with zero area mask.
Modified Paths:
--------------
trunk/blender/intern/raskter/raskter.c
Modified: trunk/blender/intern/raskter/raskter.c
===================================================================
--- trunk/blender/intern/raskter/raskter.c 2012-07-04 18:40:19 UTC (rev 48608)
+++ trunk/blender/intern/raskter/raskter.c 2012-07-04 18:49:09 UTC (rev 48609)
@@ -191,7 +191,7 @@
* If the number of verts specified to render as a polygon is less than 3,
* return immediately. Obviously we cant render a poly with sides < 3. The
* return for this we set to 1, simply so it can be distinguished from the
- * next place we could return, /home/guest/blender-svn/soc-2011-tomato/intern/raskter/raskter.
+ * next place we could return.
* which is a failure to allocate memory.
*/
if (num_verts < 3) {
@@ -215,6 +215,12 @@
*/
preprocess_all_edges(ctx, verts, num_verts, edgbuf);
+ /* can happen with a zero area mask */
+ if (ctx->all_edges == NULL) {
+ free(edgbuf);
+ return(0);
+ }
+
/*
* Set the pointer for tracking the edges currently in processing to NULL to make sure
* we don't get some crazy value after initialization.
@@ -387,7 +393,7 @@
int PLX_raskterize(float (*base_verts)[2], int num_base_verts,
float *buf, int buf_x, int buf_y, int do_mask_AA)
{
- int subdiv_AA = (do_mask_AA != 0)? 8:0;
+ int subdiv_AA = (do_mask_AA != 0) ? 8 : 0;
int i; /* i: Loop counter. */
int sAx;
int sAy;
@@ -395,7 +401,7 @@
struct r_fill_context ctx = {0};
const float buf_x_f = (float)(buf_x);
const float buf_y_f = (float)(buf_y);
- float div_offset=(1.0f / (float)(subdiv_AA));
+ float div_offset = (1.0f / (float)(subdiv_AA));
float div_offset_static = 0.5f * (float)(subdiv_AA) * div_offset;
/*
* Allocate enough memory for our poly_vert list. It'll be the size of the poly_vert
@@ -420,22 +426,22 @@
* drawn will be 1.0f in value, there is no anti-aliasing.
*/
- if(!subdiv_AA) {
+ if (!subdiv_AA) {
for (i = 0; i < num_base_verts; i++) { /* Loop over all base_verts. */
ply[i].x = (int)((base_verts[i][0] * buf_x_f) + 0.5f); /* Range expand normalized X to integer buffer-space X. */
ply[i].y = (int)((base_verts[i][1] * buf_y_f) + 0.5f); /* Range expand normalized Y to integer buffer-space Y. */
}
-
- i = rast_scan_fill(&ctx, ply, num_base_verts,1.0f); /* Call our rasterizer, passing in the integer coords for each vert. */
+
+ i = rast_scan_fill(&ctx, ply, num_base_verts, 1.0f); /* Call our rasterizer, passing in the integer coords for each vert. */
}
else {
- for(sAx=0; sAx < subdiv_AA; sAx++) {
- for(sAy=0; sAy < subdiv_AA; sAy++) {
- for(i=0; i < num_base_verts; i++) {
- ply[i].x = (int)((base_verts[i][0]*buf_x_f)+0.5f - div_offset_static + (div_offset*(float)(sAx)));
- ply[i].y = (int)((base_verts[i][1]*buf_y_f)+0.5f - div_offset_static + (div_offset*(float)(sAy)));
+ for (sAx = 0; sAx < subdiv_AA; sAx++) {
+ for (sAy = 0; sAy < subdiv_AA; sAy++) {
+ for (i = 0; i < num_base_verts; i++) {
+ ply[i].x = (int)((base_verts[i][0] * buf_x_f) + 0.5f - div_offset_static + (div_offset * (float)(sAx)));
+ ply[i].y = (int)((base_verts[i][1] * buf_y_f) + 0.5f - div_offset_static + (div_offset * (float)(sAy)));
}
- i = rast_scan_fill(&ctx, ply, num_base_verts,(1.0f / (float)(subdiv_AA*subdiv_AA)));
+ i = rast_scan_fill(&ctx, ply, num_base_verts, (1.0f / (float)(subdiv_AA * subdiv_AA)));
}
}
}
@@ -504,6 +510,12 @@
return(0);
}
+ /* can happen with a zero area mask */
+ if (ctx->all_edges == NULL) {
+ free(edgbuf);
+ return(0);
+ }
+
/*
* Do some preprocessing on all edges. This constructs a table structure in memory of all
* the edge properties and can "flip" some edges so sorting works correctly.
More information about the Bf-blender-cvs
mailing list