[Bf-blender-cvs] [efd774c] master: Fix T44231: Freestyle causes crash on render.

Tamito Kajiyama noreply at git.blender.org
Wed Oct 28 15:23:42 CET 2015


Commit: efd774ce5a8536be526935ba118a10d7b2a843ef
Author: Tamito Kajiyama
Date:   Wed Oct 28 23:09:10 2015 +0900
Branches: master
https://developer.blender.org/rBefd774ce5a8536be526935ba118a10d7b2a843ef

Fix T44231: Freestyle causes crash on render.

The reported crash was confirmed as a segmentation fault in std::sort().
The cause of the crash was traced down to a binary comparison function
that was not satisfying the so-called strict weak ordering requirements of
the C++ standard sorting function.  Specifically, the comparison operator
has to return false when two objects are equivalent (i.e., comp(a, a) must
be false), but that requirement was not met.

Since the binary comparison operator in question could be a user-defined
Python function, here a safety measure is implemented in the C++ layer to
make sure the aforementioned requirement is always satisfied.

===================================================================

M	source/blender/freestyle/intern/stroke/Operators.cpp

===================================================================

diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp
index 87ba34e..dfb50d9 100644
--- a/source/blender/freestyle/intern/stroke/Operators.cpp
+++ b/source/blender/freestyle/intern/stroke/Operators.cpp
@@ -996,6 +996,8 @@ public:
 
 	inline bool operator()(Interface1D *i1, Interface1D *i2)
 	{
+		if (i1 == i2)
+			return false;
 		if ((*_pred)(*i1, *i2) < 0)
 			throw std::runtime_error("comparison failed");
 		return _pred->result;




More information about the Bf-blender-cvs mailing list