diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-18 18:42:08 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-05-18 18:42:08 +0000 |
commit | 4fc932073df150c47d1c1a91564ea6bfacbc9a85 (patch) | |
tree | 1d5c5df801fcef7ef324ed899e4d3967255dc52e /scope.c | |
parent | 4a2d96aef46a05a49c9f496c389431f80502373c (diff) | |
download | perl-4fc932073df150c47d1c1a91564ea6bfacbc9a85.tar.gz |
Companion to #16601: cxinc would create uninitialized
PERL_CONTEXTs. The bug was tickled by the test
lib/Math/BigInt/t/upgrade.t, the new test of recurse.t
added to check that I got the context stack extension right.
Also rewrite recurse.t to use test.pl.
p4raw-id: //depot/perl@16679
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -80,8 +80,8 @@ Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems) si->si_cxmax = cxitems - 1; si->si_cxix = -1; si->si_type = PERLSI_UNDEF; - /* Needs to be Newz() because PUSHSUBST() in pp_subst() - * might otherwise read uninitialized heap. */ + /* Needs to be Newz() instead of New() because PUSHSUBST() + * in pp_subst() might otherwise read uninitialized heap. */ Newz(56, si->si_cxstack, cxitems, PERL_CONTEXT); return si; } @@ -89,8 +89,13 @@ Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems) I32 Perl_cxinc(pTHX) { + IV old_max = cxstack_max; cxstack_max = GROW(cxstack_max); Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */ + /* Needs to Zero()ed because otherwise deep enough recursion + * (such as in lib/Math/BigInt/t/upgrade.t) will end up reading + * uninitialized heap. */ + Zero(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT); return cxstack_ix + 1; } |