This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix refcount of rex attached to PL_reg_curpm
authorDavid Mitchell <davem@iabyn.com>
Sun, 27 May 2012 09:54:23 +0000 (10:54 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:54 +0000 (13:32 +0100)
commitec43f78b9ed51e88c9f6dd2f2ce15db067e4049f
treed7ea60159d404afa1fdaa19af7e392636f110c64
parent82f144941dbd0acd68cc05a3d565e1d919b0f28e
fix refcount of rex attached to PL_reg_curpm

There were two mistakes; firstly, refcounts weren't consistently managed,
leading to premature frees when recursively calling a rex via (??{}).
It should be that PL_reg_curpm holds a single ref count for the rex it
points to, and that nothing else should hold a count.

Secondly, when making PL_reg_curpm point to a new rex, increment the new
*before* decrementing the old, in case they are both the same rex.

Both of these are now enforced by doing it within the SET_reg_curpm
(formerly SETREX) macro.

Tests will come in the next commit. I can't add them yet because they
also fail for other reasons (paren related).
regexec.c