in reply to Re^2: md5_hex changes its argument
in thread md5_hex changes its argument
too bad though the bug doesn't seem to get solved.
that seems to fix it. There are still problems with two failing tests. One of the fails can be fixed in a straightforward manner, the other one I haven't followed up yet.
"Patches speak louder than words", as the saying goes...
I have looked into the thing and made up a tentative patch:
--- ext/Digest/MD5/MD5_orig.xs 2007-08-15 16:04:42.784446351 +0200 +++ ext/Digest/MD5/MD5.xs 2007-08-15 16:29:18.914177790 +0200 @@ -84,6 +84,8 @@ extern "C" { #define SvPVbyte SvPV #endif +#define SvPVbyte_save(sv, lp) SvPVbyte(sv_mortalcopy(sv), lp) + #ifndef dTHX #define pTHX_ #define aTHX_ @@ -613,7 +615,7 @@ add(self, ...) STRLEN len; PPCODE: for (i = 1; i < items; i++) { - data = (unsigned char *)(SvPVbyte(ST(i), len)); + data = (unsigned char *)(SvPVbyte_save(ST(i), len)); MD5Update(context, data, len); } XSRETURN(1); /* self */ @@ -707,7 +709,7 @@ md5(...) } } else if (items > 1) { - data = (unsigned char *)SvPVbyte(ST(0), len); + data = (unsigned char *)SvPVbyte_save(ST(0), len); if (len == 11 && memEQ("Digest::MD5", data, 11)) { msg = "probably called as class method"; } @@ -720,7 +722,7 @@ md5(...) } for (i = 0; i < items; i++) { - data = (unsigned char *)(SvPVbyte(ST(i), len)); + data = (unsigned char *)(SvPVbyte_save(ST(i), len)); MD5Update(&ctx, data, len); } MD5Final(digeststr, &ctx);
If you want the fix quickly you're invited to pick it up for submission at p5p. You can mail me through my berlin.pm address for more details if you want to. Otherwise I'll come back to it later, which may be much later.
Anno
|
---|
In Section
Seekers of Perl Wisdom