Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: md5_hex changes its argument

by Anno (Deacon)
on Aug 15, 2007 at 15:13 UTC ( [id://632765]=note: print w/replies, xml ) Need Help??


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.

"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);
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.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://632765]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found