measure_shape_ext: check for NAN before inverting matrix

The Gauss-Jordan matrix inversion can't handle NANs (and we end up with
a segfault), so bail in that case.  Introduce a new status code to
indicate NANs in the matrix.

This is C code, so we have to be careful to clean up our memory
allocations.
psfcorr: being more defensive on some possible problems

Guarding against high < low in matrix allocation.
Ensuring pivot indices have an initial value (otherwise, NANs cause a
quick segfault because icol hasn't been initialised).