ntamas / plfit

Fitting power-law distributions to empirical data, according to the method of Clauset, Shalizi and Newman
GNU General Public License v2.0
47 stars 17 forks source link

fix: logical out-of-bounds access in Zeta calculation #40

Closed jgmbenoit closed 2 years ago

jgmbenoit commented 2 years ago

This patch fixes issue #37 as follows:: 1] it may silence sanitizers by adding a NAN to the concerned arrays; 2] it emit an error message when the number of pre-coded iterations is exceeded.

szhorvat commented 2 years ago

Actually adding the NaN at the end of the array should not be necessary because with the error check, the code will never go past the end of the array. The static analysers are smart enough to see this.

jgmbenoit commented 2 years ago

I have no idea how smart are analyzers and compilers (gcc becomes more and more smart (and annoying)). On the other hand, it does not hurt to use NAN as end-of-array flag.

ntamas commented 2 years ago

Thanks a lot!