Skip to content

Commit

Permalink
Ensure string table counts are balanced. (Was not true in op/pack.t)
Browse files Browse the repository at this point in the history
p4raw-id: //depot/perl@24732
  • Loading branch information
nwc10 committed Jun 7, 2005
1 parent ce6e110 commit b8f9541
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 10 additions & 2 deletions sv.c
Expand Up @@ -4447,7 +4447,13 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
(void)SvPOK_only(dstr);

if (
(sflags & (SVf_FAKE | SVf_READONLY)) != (SVf_FAKE | SVf_READONLY)
/* We're not already COW */
((sflags & (SVf_FAKE | SVf_READONLY)) != (SVf_FAKE | SVf_READONLY)
#ifndef PERL_COPY_ON_WRITE
/* or we are, but dstr isn't a suitable target. */
|| (SvFLAGS(dstr) & CAN_COW_MASK) != CAN_COW_FLAGS
#endif
)
&&
!(isSwipe =
(sflags & SVs_TEMP) && /* slated for free anyway? */
Expand Down Expand Up @@ -4513,9 +4519,9 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
/* making another shared SV. */
STRLEN cur = SvCUR(sstr);
STRLEN len = SvLEN(sstr);
assert (SvTYPE(dstr) >= SVt_PVIV);
#ifdef PERL_COPY_ON_WRITE
if (len) {
assert (SvTYPE(dstr) >= SVt_PVIV);
/* SvIsCOW_normal */
/* splice us in between source and next-after-source. */
SV_COW_NEXT_SV_SET(dstr, SV_COW_NEXT_SV(sstr));
Expand All @@ -4528,6 +4534,8 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
UV hash = SvSHARED_HASH(sstr);
DEBUG_C(PerlIO_printf(Perl_debug_log,
"Copy on write: Sharing hash\n"));

assert (SvTYPE(dstr) >= SVt_PVIV);
SvPV_set(dstr,
sharepvn(SvPVX_const(sstr),
(sflags & SVf_UTF8?-cur:cur), hash));
Expand Down
7 changes: 3 additions & 4 deletions sv.h
Expand Up @@ -1351,16 +1351,15 @@ Like C<sv_catsv> but doesn't process magic.
# define SvRELEASE_IVX(sv) ((void)((SvFLAGS(sv) & (SVf_OOK|SVf_READONLY|SVf_FAKE)) \
&& Perl_sv_release_IVX(aTHX_ sv)))
# define SvIsCOW_normal(sv) (SvIsCOW(sv) && SvLEN(sv))
#else
# define SvRELEASE_IVX(sv) SvOOK_off(sv)
#endif /* PERL_COPY_ON_WRITE */

#define CAN_COW_MASK (SVs_OBJECT|SVs_GMG|SVs_SMG|SVs_RMG|SVf_IOK|SVf_NOK| \
SVf_POK|SVf_ROK|SVp_IOK|SVp_NOK|SVp_POK|SVf_FAKE| \
SVf_OOK|SVf_BREAK|SVf_READONLY|SVf_AMAGIC)
#define CAN_COW_FLAGS (SVp_POK|SVf_POK)

#else
# define SvRELEASE_IVX(sv) SvOOK_off(sv)
#endif /* PERL_COPY_ON_WRITE */

#define SV_CHECK_THINKFIRST(sv) if (SvTHINKFIRST(sv)) \
sv_force_normal_flags(sv, 0)

Expand Down

0 comments on commit b8f9541

Please sign in to comment.