summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-04-15 14:24:17 +0300
committerNicholas Clark <nick@ccl4.org>2006-04-15 10:51:48 +0000
commit002e75cfc4ef18da0a4adbabb92d675c0c36aaa5 (patch)
tree7a1aa96bc51d7fcb0a77de2c0722408bbcf9f3f9 /perlio.c
parentf02a1854b11a89ea387fda8722502f6110e043dc (diff)
downloadperl-002e75cfc4ef18da0a4adbabb92d675c0c36aaa5.tar.gz
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
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c31
1 files changed, 19 insertions, 12 deletions
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) {