Skip to content

Commit

Permalink
Stop B from crashing on y/å/ø/
Browse files Browse the repository at this point in the history
  • Loading branch information
Father Chrysostomos committed Nov 4, 2010
1 parent 7e31b64 commit 512ba29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ext/B/B.xs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,17 @@ cc_opclass(pTHX_ const OP *o)
* Character translations (tr///) are usually a PVOP, keeping a
* pointer to a table of shorts used to look up translations.
* Under utf8, however, a simple table isn't practical; instead,
* the OP is an SVOP, and the SV is a reference to a swash
* the OP is an SVOP (or, under threads, a PADOP),
* and the SV is a reference to a swash
* (i.e., an RV pointing to an HV).
*/
return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
#if defined(USE_ITHREADS) \
&& (PERL_VERSION > 8 || (PERL_VERSION == 8 && PERL_SUBVERSION >= 9))
? OPc_PADOP : OPc_PVOP;
#else
? OPc_SVOP : OPc_PVOP;
#endif

case OA_LOOP:
return OPc_LOOP;
Expand Down
4 changes: 4 additions & 0 deletions ext/B/t/b.t
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,8 @@ is(B::opnumber("chop"), 38, "Testing opnumber with opname (chop)");
is(B::svref_2object(sub {})->ROOT->ppaddr, 'PL_ppaddr[OP_LEAVESUB]',
'OP->ppaddr');

# This one crashes from perl 5.8.9 to B 1.24 (perl 5.13.6):
B::svref_2object(sub{y/\x{100}//})->ROOT->first->first->sibling->sv;
ok 1, 'B knows that UTF trans is a padop in 5.8.9, not an svop';

done_testing();

0 comments on commit 512ba29

Please sign in to comment.