Skip Menu |

This queue is for tickets about the Digest-SHA1 CPAN distribution.

Report information
The Basics
Id: 59071
Status: resolved
Priority: 0/
Queue: Digest-SHA1

People
Owner: Nobody in particular
Requestors: MIKEM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 2.10
  • 2.11
  • 2.12
Fixed in: (no value)



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.
Thanks for your report. I applied your patch as <http://github.com/gisle/digest- sha1/commit/a099a4f694dc2d5eae3f01e5d9b90d2c7c7586f5>