there is a memory leak in Digest::SHA1::sha1_transform in all versions
up to 2.12. Tested with perl 5.10 on opensuse 11.1
You can demonstrate this with a program like this. It quickly grows
unbounded in size:
use Digest::SHA1;
my $mk = pack('H*', '4ccb17537e376bb935f51d33f8dfd0d5874f367b');
while (1)
{
Digest::SHA1::sha1_transform($mk);
}
The fix is also simple:
--- Digest-SHA1-2.12/SHA1.xs 2009-05-23 20:51:46.000000000 +1000
+++ Digest-SHA1-2.12.mikem//SHA1.xs 2010-07-02 17:00:50.000000000
+1000
@@ -617,6 +617,6 @@
memcpy (test, data_pv, len);
memcpy ((&ctx)->data, test, 64);
sha_transform_and_copy(digeststr, &ctx);
- ST(0) = newSVpv((char*)digeststr, 20);
+ ST(0) = make_mortal_sv(aTHX_ digeststr, F_BIN);
XSRETURN(1);
Cheers.