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


In reply to Re^3: md5_hex changes its argument by Anno
in thread md5_hex changes its argument by tinita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.