summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-07-07 00:32:38 -0500
committerJesse Luehrs <doy@tozt.net>2011-07-07 00:32:38 -0500
commit93fb77c98e002f21858fe9efa1bf6a8ce2144178 (patch)
treef7a0d259f6b8ad990c46f991f82e2aafd8280e93
parentd46ca6eacf7d512ac6d20dda977a4a33f9d4717c (diff)
downloadsmartmatch-93fb77c98e002f21858fe9efa1bf6a8ce2144178.tar.gz
smartmatch-93fb77c98e002f21858fe9efa1bf6a8ce2144178.zip
oops, need a new ref to the cv for each op
-rw-r--r--smartmatch.xs9
-rw-r--r--t/basic.t2
2 files changed, 9 insertions, 2 deletions
diff --git a/smartmatch.xs b/smartmatch.xs
index b3e12c5..28cf0e0 100644
--- a/smartmatch.xs
+++ b/smartmatch.xs
@@ -17,7 +17,7 @@ smartmatch_cb(pTHX_ OP *o, void *user_data)
o->op_flags &= ~OPf_KIDS;
op_free(o);
- cb_op = newSVOP(OP_CONST, 0, (SV*)user_data);
+ cb_op = newSVOP(OP_CONST, 0, newSVsv(user_data));
list = newLISTOP(OP_LIST, 0, left, right);
new = newUNOP(OP_ENTERSUB, OPf_STACKED,
op_append_elem(OP_LIST, list, cb_op));
@@ -56,5 +56,10 @@ register (cb)
void
unregister (id)
UV id;
+ PREINIT:
+ SV *cb;
CODE:
- hook_op_check_smartmatch_remove(id);
+ cb = hook_op_check_smartmatch_remove(id);
+ if (cb) {
+ SvREFCNT_dec(cb);
+ }
diff --git a/t/basic.t b/t/basic.t
index b7010e2..1de7d8f 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -7,12 +7,14 @@ ok(1 ~~ 1);
{
use smartmatch sub { 0 };
ok(!(1 ~~ 1));
+ ok(!(1 ~~ 2));
}
ok(1 ~~ 1);
{
use smartmatch 'core';
ok(1 ~~ 1);
+ ok(!(1 ~~ 2));
}
done_testing;