return o;
}
+/* XXX kept for BINCOMPAT only */
void
Perl_save_hints(pTHX)
{
- SAVEI32(PL_hints);
- SAVESPTR(GvHV(PL_hintgv));
- GvHV(PL_hintgv) = newHVhv(GvHV(PL_hintgv));
- SAVEFREESV(GvHV(PL_hintgv));
+ Perl_croak(aTHX_ "internal error: obsolete function save_hints() called");
}
int
GvHV(PL_hintgv) = NULL;
}
*(I32*)&PL_hints = (I32)SSPOPINT;
+ if (PL_hints & HINT_LOCALIZE_HH) {
+ SvREFCNT_dec((SV*)GvHV(PL_hintgv));
+ GvHV(PL_hintgv) = (HV*)SSPOPPTR;
+ }
+
break;
case SAVEt_COMPPAD:
PL_comppad = (PAD*)SSPOPPTR;
#define SAVEOP() save_op()
#define SAVEHINTS() \
- STMT_START { \
- if (PL_hints & HINT_LOCALIZE_HH) \
- save_hints(); \
- else { \
- SSCHECK(2); \
- SSPUSHINT(PL_hints); \
- SSPUSHINT(SAVEt_HINTS); \
- } \
+ STMT_START { \
+ SSCHECK(3); \
+ if (PL_hints & HINT_LOCALIZE_HH) { \
+ SSPUSHPTR(GvHV(PL_hintgv)); \
+ GvHV(PL_hintgv) = newHVhv(GvHV(PL_hintgv)); \
+ } \
+ SSPUSHINT(PL_hints); \
+ SSPUSHINT(SAVEt_HINTS); \
} STMT_END
#define SAVECOMPPAD() \
# Tests the scoping of $^H and %^H
-BEGIN { print "1..14\n"; }
+BEGIN { print "1..15\n"; }
BEGIN {
print "not " if exists $^H{foo};
print "ok 1 - \$^H{foo} doesn't exist initially\n";
print "not " if $^H & 0x00020000;
print "ok 8 - \$^H doesn't contain HINT_LOCALIZE_HH while finishing compilation\n";
}
+
+require 'test.pl';
+
+# bug #27040: hints hash was being double-freed
+my $result = runperl(
+ prog => '$^H |= 0x20000; eval q{BEGIN { $^H |= 0x20000 }}',
+ stderr => 1
+);
+print "not " if length $result;
+print "ok 15 - double-freeing hints hash\n";
+print "# got: $result\n" if length $result;
+