develooper Front page | perl.perl5.porters | Postings from October 2016

Re: Encode.xs and sv_force_normal

Thread Previous | Thread Next
October 10, 2016 18:46
Re: Encode.xs and sv_force_normal
Message ID:
On Thursday 29 September 2016 21:22:26 wrote:
> Hi!
> Look at cpan/Encode/Encode.xs for XS functions. Every one has different
> check if first argument can be modified or not. Some functions have
> SvPOK() check, some SvREADONLY(), SvSMAGICAL(src), SvGMAGICAL() and some
> SvIsCOW().
> After these check every XS function calling either sv_force_normal() or
> sv_mortalcopy() or sv_newmortal()+sv_copypv(). And some none.
> In apidoc is documented macro SvTHINKFIRST() which I understand is that
> which needs to be called for checking if sv_force_normal() is needed or
> not.
> I believe that for calling sv_utf8_upgrade() is needed to call
> sv_mortalcopy() first (to prevent modification of input scalar).
> Can some expert look at that code if this is enough to make sv argument
> modifiable?
> if (SvTHINKFIRST(sv)) sv_force_normal(sv)
> I think because of this problem in Encode (which is in core) there are
> bugs like these:
> (PS: please CC me as I'm not subscribed to this high volume list)

Hi! I prepared patch for Encode which should fix those problems with
readonly, magic, COW, ... scalars. Can you look at it? It is correct now?

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