aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2019-05-22 12:09:47 -0400
committertlatorre <tlatorre@uchicago.edu>2019-05-22 12:09:47 -0400
commit04dd1f0c2369980fd474853bacf8047b3d2be074 (patch)
tree730cfb3237262ce969f6676b1e020272dd79365f
parent736542009a2ef7f21ecbf14ca260588dd78d6d6a (diff)
downloadsddm-04dd1f0c2369980fd474853bacf8047b3d2be074.tar.gz
sddm-04dd1f0c2369980fd474853bacf8047b3d2be074.tar.bz2
sddm-04dd1f0c2369980fd474853bacf8047b3d2be074.zip
make sure theta0 is less than MAX_THETA0 in get_probability() to prevent a gsl error
-rw-r--r--src/scattering.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/scattering.c b/src/scattering.c
index 5a7f7a9..c4babae 100644
--- a/src/scattering.c
+++ b/src/scattering.c
@@ -219,6 +219,10 @@ double get_probability(double beta, double cos_theta, double theta0)
* we are going to square it everywhere. */
sin_theta = sqrt(1-pow(cos_theta,2));
+ /* Make sure theta0 is less than MAX_THETA0, otherwise it's possible that
+ * gsl_spline2d_eval() will quit. */
+ if (theta0 > MAX_THETA0) theta0 = MAX_THETA0;
+
return gsl_spline2d_eval(spline, beta*cos_theta, beta*sin_theta*theta0, xacc, yacc)/(theta0*sin_theta);
}