OpenGamma/OG-Maths — pull request #120 by stuartarchibald (2014-07-08 09:48:46+00:00)
Title: Mat-441Fix segfault occuring in pinv()

The fuzzer spotted a segfault in the `pinv()` function, turns out this was from an invalid loop induction setting a limit of type `size_t` to `-1`, this limit was then used as a upper bound to index an array and hence segfaulted!

To fix this:
* A branch to test for all zeros in the input matrix is added, this is quicker to handle than a SVD anyway and allows an early escape.
* The offending loop is now patched and a further branch is added should it be possible to escape early when all singular values are below the threshold (this branch is not tested as it is a safety net and I'm not wholly convinced it's even reachable!).
* The svd runner is also patched to use smart pointer managed memory.

Coverage:
Java: 77% (no change)
build/src/jshim 0.8% (no change)
build/src/librdag 17.1% (no change)
src/jshim 53.1% (no change)
src/librdag 94.2% (no change)
src/librdag/runners 94.6% (up 0.1%).