From a78b4209f10c0ea66992258245a53ad4324aa05e Mon Sep 17 00:00:00 2001 From: James Willis <james.s.willis@durham.ac.uk> Date: Thu, 1 Dec 2016 11:05:17 +0000 Subject: [PATCH] Make sure the sum is greater than zero before performing division. --- src/tools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools.c b/src/tools.c index 879ab1dae1..c8ab358120 100644 --- a/src/tools.c +++ b/src/tools.c @@ -578,7 +578,9 @@ int compare_values(double a, double b, double threshold, double *absDiff, *absDiff = fabs(a - b); *absSum = fabs(a + b); - *relDiff = *absDiff / *absSum; + if( *absSum > 0.f) { + *relDiff = *absDiff / *absSum; + } if (*relDiff > threshold) { result = 1; -- GitLab