Subject: | Memory leak in modinv |
When testing other software using Test::Valgrind I found this leak.
In GMP.xs, line 551 in _modinv, in the path where we return undefs, we should be doing:
{
/* Inverse doesn't exist. Return both values undefined. */
PUSHs ( &PL_sv_undef );
PUSHs ( &PL_sv_undef );
mpz_clear(*RETVAL);
free(RETVAL);
}
Because we've allocated RETVAL but we're not returning it in any way, so it is leaked.