added checks to mitigate floating point crashes
This commit is contained in:
@@ -53,7 +53,10 @@ static float relativeSimilarity(const QString &str1, const QString &str2)
|
||||
}
|
||||
}
|
||||
|
||||
return z == 0 ? 0.f : float(z) / std::max(str1.size(), str2.size());
|
||||
// ensure that no div by 0
|
||||
return z == 0 ? 0.f
|
||||
: float(z) /
|
||||
std::max<int>(1, std::max(str1.size(), str2.size()));
|
||||
};
|
||||
|
||||
float IrcMessageHandler::similarity(
|
||||
|
||||
Reference in New Issue
Block a user