Skip to content

Commit bb59fb2

Browse files
committed
sv_clear: with zero SvREFCNT, call sv_free2, not sv_free
Towards the bottom of `Perl_sv_clear`, there is a region described as being `* unrolled SvREFCNT_dec and sv_free2 follows: */`. This was introduced in 5239d5c but the definitions of `Perl_sv_free`, `Perl_sv_free2`, and `SvREFCNT_dec` were updated in 75a9bf9 and this region of code didn't get updated. The unrolling remains valid, but the call to `sv_free(sv)` ultimately boils down to a call to `sv_free2`, so this commit just goes there directly.
1 parent 00f06a3 commit bb59fb2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sv.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7120,12 +7120,18 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
71207120
}
71217121
}
71227122

7123-
/* unrolled SvREFCNT_dec and sv_free2 follows: */
7123+
/* Do the equivalent of SvREFCNT_dec(sv), except:
7124+
- for the case of RC==1, inline the actions normally taken
7125+
by sv_free2() prior it calling sv_clear(), and handle the
7126+
sv_clear() actions ourselves (without needing to
7127+
recurse).
7128+
- For the exceptional case of RC==0, do a traditional
7129+
recursive free. */
71247130

71257131
if (!sv)
71267132
continue;
71277133
if (!SvREFCNT(sv)) {
7128-
sv_free(sv);
7134+
Perl_sv_free2(aTHX_ sv, 0);
71297135
continue;
71307136
}
71317137
if (--(SvREFCNT(sv)))

0 commit comments

Comments
 (0)