From: Jarkko Hietaniemi Date: Sat, 15 Apr 2006 11:24:17 +0000 (+0300) Subject: perlio.c: layer data might be allocated and unused (Coverity) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=002e75cfc4ef18da0a4adbabb92d675c0c36aaa5;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/perlio.c b/perlio.c index 8a93acb..0b010b8 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) {