GuillaumeGomez / rust-GSL

A GSL (the GNU Scientific Library) binding for Rust
190 stars 46 forks source link

legendre_Pl_array and legendre_Pl_deriv_array are broken #129

Closed H-M-H closed 1 year ago

H-M-H commented 1 year ago

The gsl docs state:

These functions compute arrays of Legendre polynomials P_l(x) and derivatives dP_l(x)/dx for l = 0, \dots, lmax and |x| \le 1.

That is the parameter l is not the size of the array for the results. Thus the following is wrong: https://github.com/GuillaumeGomez/rust-GSL/blob/c21148fc63946dfa8a19e9894d830fd6de28ce33/src/legendre.rs#L75

Like that gsl tries to write to the address after the last array element resulting in undefined behavior.

GuillaumeGomez commented 1 year ago

Indeed, thanks!