Skip to content

Don't try to free an already-freed SV. #21416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mg.c
Original file line number Diff line number Diff line change
@@ -544,6 +544,9 @@ Perl_mg_free(pTHX_ SV *sv)

PERL_ARGS_ASSERT_MG_FREE;

if (SvIS_FREED(sv))
return 0;

for (mg = SvMAGIC(sv); mg; mg = moremagic) {
moremagic = mg->mg_moremagic;
mg_free_struct(sv, mg);
5 changes: 5 additions & 0 deletions sv.c
Original file line number Diff line number Diff line change
@@ -5932,6 +5932,8 @@ S_sv_unmagicext_flags(pTHX_ SV *const sv, const int type, const MGVTBL *vtbl, co

if (SvTYPE(sv) < SVt_PVMG || !SvMAGIC(sv))
return 0;
if (SvIS_FREED(sv))
return 0;
mgp = &(((XPVMG*) SvANY(sv))->xmg_u.xmg_magic);
for (mg = *mgp; mg; mg = *mgp) {
const MGVTBL* const virt = mg->mg_virtual;
@@ -6939,6 +6941,9 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
U32 arena_index;
const struct body_details *sv_type_details;

if (SvIS_FREED(sv))
goto get_next_sv;

if (type == SVt_PVHV && HvHasAUX(sv)) {
arena_index = HVAUX_ARENA_ROOT_IX;
sv_type_details = &fake_hv_with_aux;