diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-12-20 21:57:04 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-12-22 09:48:23 -0700 |
commit | ed92f1b349486018652c315fcb8564cfc3925893 (patch) | |
tree | de7380f3691fc19318c56b055e591afc73037e93 | |
parent | 5df2f14060151be4cc3b594dc3d3b06711029df2 (diff) | |
download | perl-ed92f1b349486018652c315fcb8564cfc3925893.tar.gz |
utf8.c: Fix reference count in swash_to_invlist()
The return SV* from this function was inconsistent in its reference
count. In some cases it creates a new SV, which has a reference count
of 1, and in some cases it returned an existing SV without incrementing
the reference count. If the caller thought it was getting its own copy,
and decremented the reference count, it could lead to a double free.
-rw-r--r-- | utf8.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3976,7 +3976,8 @@ SV* Perl__swash_to_invlist(pTHX_ SV* const swash) { - /* Subject to change or removal. For use only in one place in regcomp.c */ + /* Subject to change or removal. For use only in one place in regcomp.c. + * Ownership is given to one reference count in the returned SV* */ U8 *l, *lend; char *loc; @@ -4002,7 +4003,7 @@ Perl__swash_to_invlist(pTHX_ SV* const swash) /* If not a hash, it must be the swash's inversion list instead */ if (SvTYPE(hv) != SVt_PVHV) { - return (SV*) hv; + return SvREFCNT_inc_simple_NN((SV*) hv); } /* The string containing the main body of the table */ |