From 002e75cfc4ef18da0a4adbabb92d675c0c36aaa5 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sat, 15 Apr 2006 14:24:17 +0300 Subject: perlio.c: layer data might be allocated and unused (Coverity) Message-Id: <20060415082417.24F0A6D08C@ugli.hut.fi> (with a correction) p4raw-id: //depot/perl@27809 --- perlio.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'perlio.c') diff --git a/perlio.c b/perlio.c index 8a93acbd6a..0b010b84bc 100644 --- a/perlio.c +++ b/perlio.c @@ -1182,19 +1182,26 @@ PerlIO_push(pTHX_ PerlIO *f, PERLIO_FUNCS_DECL(*tab), const char *mode, SV *arg) goto mismatch; } /* Real layer with a data area */ - Newxc(l,tab->size,char,PerlIOl); - if (l && f) { - Zero(l, tab->size, char); - l->next = *f; - l->tab = (PerlIO_funcs*) tab; - *f = l; - PerlIO_debug("PerlIO_push f=%p %s %s %p\n", (void*)f, tab->name, - (mode) ? mode : "(Null)", (void*)arg); - if (*l->tab->Pushed && - (*l->tab->Pushed) (aTHX_ f, mode, arg, (PerlIO_funcs*) tab) != 0) { - PerlIO_pop(aTHX_ f); - return NULL; + if (f) { + char *temp; + Newxz(temp, tab->size, char); + l = (PerlIOl*)temp; + if (l) { + l->next = *f; + l->tab = (PerlIO_funcs*) tab; + *f = l; + PerlIO_debug("PerlIO_push f=%p %s %s %p\n", + (void*)f, tab->name, + (mode) ? mode : "(Null)", (void*)arg); + if (*l->tab->Pushed && + (*l->tab->Pushed) + (aTHX_ f, mode, arg, (PerlIO_funcs*) tab) != 0) { + PerlIO_pop(aTHX_ f); + return NULL; + } } + else + return NULL; } } else if (f) { -- cgit v1.2.1