Change 27809 by [EMAIL PROTECTED] on 2006/04/15 10:51:48

        Subject: [PATCH] perlio.c: layer data might be allocated and unused 
(Coverity)
        From: [EMAIL PROTECTED] (Jarkko Hietaniemi)
        Message-Id: <[EMAIL PROTECTED]>
        Date: Sat, 15 Apr 2006 11:24:17 +0300 (EEST)
        
        (with a correction)

Affected files ...

... //depot/perl/perlio.c#315 edit

Differences ...

==== //depot/perl/perlio.c#315 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#314~27798~    2006-04-14 04:50:56.000000000 -0700
+++ perl/perlio.c       2006-04-15 03:51:48.000000000 -0700
@@ -1182,19 +1182,26 @@
            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) {
End of Patch.

Reply via email to