diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2003-05-10 02:45:23 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2003-05-11 20:06:03 +0000 |
commit | 815f25c6e302f84ecce02c74fa717a19d787f662 (patch) | |
tree | 375a44792420e7d61ab304dec3eee30530983e56 /pp_ctl.c | |
parent | 3ebac25bf00794df08226119e9ae3699268f48dc (diff) | |
download | perl-815f25c6e302f84ecce02c74fa717a19d787f662.tar.gz |
[perl #7391] Perl crashes with certain write() formats.
Message-ID: <20030510004523.GC20871@fdgroup.com>
p4raw-id: //depot/perl@19496
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -3573,11 +3573,20 @@ S_doparseform(pTHX_ SV *sv) U16 *linepc = 0; register I32 arg; bool ischop; + int maxops = 2; /* FF_LINEMARK + FF_END) */ if (len == 0) Perl_croak(aTHX_ "Null picture in formline"); - New(804, fops, (send - s)*3+10, U16); /* Almost certainly too long... */ + /* estimate the buffer size needed */ + for (base = s; s <= send; s++) { + if (*s == '\n' || *s == '@' || *s == '^') + maxops += 10; + } + s = base; + base = Nullch; + + New(804, fops, maxops, U16); fpc = fops; if (s < send) { @@ -3740,6 +3749,7 @@ S_doparseform(pTHX_ SV *sv) } *fpc++ = FF_END; + assert (fpc <= fops + maxops); /* ensure our buffer estimate was valid */ arg = fpc - fops; { /* need to jump to the next word */ int z; |