summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2017-02-28 11:23:09 +0000
committerDavid Mitchell <davem@iabyn.com>2017-03-15 09:17:08 +0000
commit00195859c65eccf9425faf45db543a12c7ad3874 (patch)
treecd04c70326c16ed06553a6608564bd8237b888b6 /perlio.c
parentacfc2cc32784cce84bd781bc3822b14406b94db2 (diff)
downloadperl-00195859c65eccf9425faf45db543a12c7ad3874.tar.gz
update size after Renew
RT #130841 In general code, change this idiom: PL_foo_max += size; Renew(PL_foo, PL_foo_max, foo_t); to Renew(PL_foo, PL_foo_max + size, foo_t); PL_foo_max += size; so that if Renew dies, PL_foo_max won't be left hanging.
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/perlio.c b/perlio.c
index 3e936a26d0..e9d3700cfe 100644
--- a/perlio.c
+++ b/perlio.c
@@ -547,11 +547,12 @@ PerlIO_list_push(pTHX_ PerlIO_list_t *list, PerlIO_funcs *funcs, SV *arg)
PERL_UNUSED_CONTEXT;
if (list->cur >= list->len) {
- list->len += 8;
+ const IV new_len = list->len + 8;
if (list->array)
- Renew(list->array, list->len, PerlIO_pair_t);
+ Renew(list->array, new_len, PerlIO_pair_t);
else
- Newx(list->array, list->len, PerlIO_pair_t);
+ Newx(list->array, new_len, PerlIO_pair_t);
+ list->len = new_len;
}
p = &(list->array[list->cur++]);
p->funcs = funcs;