Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-13 09:32:02 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-13 09:32:02 +0400
commit190144ef6eae94b989c992595d043845242bd8e1 (patch)
tree0561e0ee98febe8f9df7a016c092602e3c6d55fa /source/blender/freestyle
parentac9ec06ec121589fedbfeaa10137140b45bfd668 (diff)
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!
Diffstat (limited to 'source/blender/freestyle')
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index dd6e6dc317e..73651e7d672 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -955,11 +955,13 @@ public:
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 @@ int PolygonalizationShader::shade(Stroke& stroke) const
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);