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

Re: Encode.xs and sv_force_normal

Thread Previous | Thread Next
From:
pali
Date:
October 10, 2016 18:46
Subject:
Re: Encode.xs and sv_force_normal
Message ID:
20161010165956.GA22435@pali
On Thursday 29 September 2016 21:22:26 pali@cpan.org 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:
> 
> https://rt.cpan.org/Public/Bug/Display.html?id=117158
> https://github.com/dankogai/p5-encode/pull/66
> 
> (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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About