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.
This commit is contained in:
Tamito Kajiyama 2015-10-28 23:09:10 +09:00
parent ced1c34f74
commit efd774ce5a
Notes: blender-bot 2023-02-14 11:07:28 +01:00
Referenced by issue #44231, Freestyle causes crash on render
1 changed files with 2 additions and 0 deletions

View File

@ -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;