develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [perl #33185] UTF-8 string substitution corrupts memory

Thread Previous
Nicholas Clark
December 31, 2004 07:37
Re: [perl #33185] UTF-8 string substitution corrupts memory
Message ID:
On Fri, Dec 31, 2004 at 03:04:49PM +0000, wrote:
> Nicholas Clark <> wrote:
> :The appended patch seems to cure the problem for me, but I'm not confident
> :that it's the correct way.
> I notice that this changes the order things are stacked; I'm not sure if
> that's ever going to be relevant. In particularly this swaps the first
> two of the sequence:
> .. but I'm not sure what they all do without expanding a lot of macros.

Aha. I was rather hoping that someone would be able to tell me if the changes
were going to be relevant. The "simplest" fix appears to be add
save_re_context(); after the ENTER in

    if (!gv_fetchmeth(stash, "SWASHNEW", 8, -1)) {	/* demand load utf8 */
	errsv_save = newSVsv(ERRSV);
	Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn(pkg,pkg_len),
	if (!SvTRUE(ERRSV))
	    sv_setsv(ERRSV, errsv_save);

except that seems to be wasteful, as it would mean doing all the save work
twice, because of the existing save_re_context() later in Perl_swatch_init.
I was hoping that there was a good way to save the regexp engine's context
just once for the entire function.

Nicholas Clark

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About