[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54518] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/stroke/BasicStrokeShaders.cpp: Fix for a crash when the Polygonization geometry modifier is used with a small "error"

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Wed Feb 13 06:32:02 CET 2013


Revision: 54518
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54518
Author:   kjym3
Date:     2013-02-13 05:32:02 +0000 (Wed, 13 Feb 2013)
Log Message:
-----------
Fix for a crash when the Polygonization geometry modifier is used with a small "error"
parameter value.  The problem was caused by a null pointer reference in CurvePiece::error()
resulting from incorrect lengths of subdivided curves calculated in CurvePiece::subdivide().
Problem report by IRIE Shinsuke with a GDB backtrace log, many thanks!

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp	2013-02-13 05:28:51 UTC (rev 54517)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp	2013-02-13 05:32:02 UTC (rev 54518)
@@ -955,11 +955,13 @@
 	CurvePiece *subdivide()
 	{
 		StrokeInternal::StrokeVertexIterator it = _begin;
-		int actualSize = (size > 1) ? size / 2 : 1;
-		for (int i = 0; i <= actualSize; ++it, ++i);
+		int ns = size - 1; // number of segments (ns > 1)
+		int ns1 = ns / 2;
+		int ns2 = ns - ns1;
+		for (int i = 0; i < ns1; ++it, ++i);
 
-		CurvePiece *second = new CurvePiece(it, _last, size - actualSize + 1);
-		size = actualSize;
+		CurvePiece *second = new CurvePiece(it, _last, ns2 + 1);
+		size = ns1 + 1;
 		_last = it;
 		B = Vec2d((_last)->x(), (_last)->y());
 		return second;
@@ -984,7 +986,7 @@
 	while (!_pieces.empty()) {
 		piece = _pieces.back();
 		_pieces.pop_back();
-		if (piece->error() > _error) {
+		if (piece->size > 2 && piece->error() > _error) {
 			CurvePiece *second = piece->subdivide();
 			_pieces.push_back(second);
 			_pieces.push_back(piece);




More information about the Bf-blender-cvs mailing list