Permalink
Browse files

Workaround an optimization bug in Clustering code that could lead to …

…a crash

For some reason, a component of center has a NaN value, and if you multiply
NaN * 0, the result is still NaN. This causes a check to fail and allows
meanObj to remain nullptr, which is then dereferenced leading to a segfault.

This commit explicty forces all the components of center to be 0.0f.

Fixes #851
  • Loading branch information...
DolceTriade committed Dec 29, 2015
1 parent bb449a7 commit d8826b6bca4cbed0f502d2c1462670690ff8aae8
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/sgame/Clustering.cpp
@@ -104,7 +104,9 @@ namespace Clustering {
void UpdateMetadata() {
dirty = false;

center *= 0.0f;
for (int i = 0; i < Dim; ++i) {
center[i] = 0.0f;
}
meanObject = nullptr;
averageDistance = 0;
standardDeviation = 0;

0 comments on commit d8826b6

Please sign in to comment.