CosmoStat / Glimpse

Sparsity based weak lensing mass-mapping tool
Other
6 stars 5 forks source link

Missing check on SVD decomposition #17

Open giordano opened 5 years ago

giordano commented 5 years ago

If SVD decomposition fails at https://github.com/CosmoStat/Glimpse/blob/3e01fcec1f8e8d6b53c66e33071c240724bd2ead/src/field.cpp#L936 then s is reset and the following instruction s( 0 ) causes the program to terminate with the following error:

error: Mat::operator(): index out of bounds
terminate called after throwing an instance of 'std::logic_error'
  what():  Mat::operator(): index out of bounds

svd function actually returns a bool flag to indicate whether decomposition was successful or not. Glimpse should check the value of the returned flag and deal with the case where the decomposition failed.