- if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
- SvTYPE(sv) != SVt_PVGV)
- {
- (void)SvUPGRADE(value, SvTYPE(sv));
- SvMAGIC(value) = SvMAGIC(sv);
- SvFLAGS(value) |= SvMAGICAL(sv);
- SvMAGICAL_off(sv);
- SvMAGIC(sv) = 0;
- }
- /* XXX This branch is pretty bogus. This code irretrievably
- * clears(!) the magic on the SV (either to avoid further
- * croaking that might ensue when the SvSETMAGIC() below is
- * called, or to avoid two different SVs pointing at the same
- * SvMAGIC()). This needs a total rethink. --GSAR */
- else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
- SvTYPE(value) != SVt_PVGV)
- {
- SvFLAGS(value) |= (SvFLAGS(value) &
- (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
- SvMAGICAL_off(value);
- /* XXX this is a leak when we get here because the
- * mg_get() in save_scalar_at() croaked */
- SvMAGIC(value) = 0;
- }
- SvREFCNT_dec(sv);