develooper Front page | perl.perl5.porters | Postings from January 2013

Re: [perl #116407] SvPVutf8 != SvPVX, and sv_2pvutf8

Thread Previous | Thread Next
Tony Cook
January 15, 2013 23:36
Re: [perl #116407] SvPVutf8 != SvPVX, and sv_2pvutf8
Message ID:
On Tue, Jan 15, 2013 at 01:24:29PM -0800, bulk88 wrote:
> I recently found a bug in a core module, where a loop was done over a 
> string from SvPVutf8(sv, len) to SvEND(sv). The sv is a RO literal SV. 
> So it looped over uninitialized memory and sometimes segvs.
> A mortal copy was made of the RO SV was made and returned as the result 
> of SvPVutf8.
> All that SvPVutf8's docs say is "Like C<SvPV>, but converts sv to utf8 
> first if necessary."
> SvPV says "The SV may cache the stringified version becoming C<SvPOK>." 
> So that is the disclaimer that SvPVX after SvPV is not the same pointer 
> as returned from SvPV. I think the docs can be improved for SvPVutf8 and 
> maybe SvPV to make it more obvious that these 2 do not create POK SVs. I 
> don't have any proposed wording so no patch is included.
> This ticket might be related to 
> and .


  Like C<SvPV>, but returns always returns a utf8 string.

	char*	SvPVutf8(SV* sv, STRLEN len)

  This may return a pointer to a temporary instead of C<SvPVX(sv)>.

The other SvPVutf8* macros should be updated too.


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