Skip to content

Commit

Permalink
THX_ck_entersub_args_sereal_decoder(): set parent link correctly
Browse files Browse the repository at this point in the history
This patch was originally provided by Dave Mitchell inline as a response
to a "Blead Breaks CPAN" report in the Perl 5 bug queue (originally
rt.perl.org; now github.com/Perl/perl5/issues).  Dave's comment in
original ticket.

    THX_ck_entersub_args_sereal_decoder() in Decoder.xs
    wasn't setting the parent link correctly when munging an op
    tree.  The following diff makes all tests pass on blead. I
    haven't tested against older perls.

References:

Perl/perl5#17114
(originally https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134320)

Sereal#207
  • Loading branch information
iabyn authored and jkeenan committed Nov 3, 2019
1 parent 0b8ac45 commit 6153fd0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Perl/Decoder/Decoder.xs
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,17 @@ THX_ck_entersub_args_sereal_decoder(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
if (arity > min_arity)
opopt |= OPOPT_OUTARG_HEADER;

OpMORESIB_set(pushop, cvop);
OpLASTSIB_set(lastargop, op_parent(lastargop));
/* cut out all ops between the pushmark and the RV2CV */
op_sibling_splice(NULL, pushop, arity, NULL);
/* then throw everything else out */
op_free(entersubop);
newop = newUNOP(OP_NULL, 0, firstargop);
newop = newUNOP(OP_NULL, 0, NULL);
newop->op_type = OP_CUSTOM;
newop->op_private = opopt;
newop->op_ppaddr = opopt & OPOPT_LOOKS_LIKE ? THX_pp_looks_like_sereal : THX_pp_sereal_decode;
/* attach the spliced-out args as children of the custom op, while
* deleting the stub op created by newUNOP() */
op_sibling_splice(newop, NULL, 1, firstargop);
return newop;
}

Expand Down

0 comments on commit 6153fd0

Please sign in to comment.