utf8.c: Fix a minor refcounting bug caused by 02c8547
authorFather Chrysostomos <sprout@cpan.org>
Mon, 19 Nov 2012 02:44:16 +0000 (18:44 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 19 Nov 2012 04:17:18 +0000 (20:17 -0800)
Under some circumstances it could cause a hash to point to a freed
element.  But the hash itself was leaking, so it caused on problems,
as no attempt to free its element again was made.

The next commit will stop the hash from leaking.

utf8.c

diff --git a/utf8.c b/utf8.c
index bde7f87..62b9135 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2998,6 +2998,9 @@ Perl__core_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 m
             {
                Perl_croak(aTHX_ "panic: hv_store() unexpectedly failed");
            }
+           /* We just stole a reference count. */
+           if (swash_invlist_unclaimed) swash_invlist_unclaimed = FALSE;
+           else SvREFCNT_inc_simple_void_NN(swash_invlist);
        }
 
         if ((int) _invlist_len(swash_invlist) <= invlist_swash_boundary) {