OSDN Git Service

(finclude): Set fp->buf earlier, so it's freed on error.
authorrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Oct 1992 07:57:31 +0000 (07:57 +0000)
committerrms <rms@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Oct 1992 07:57:31 +0000 (07:57 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@2348 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cccp.c

index 5e055be..adaec46 100644 (file)
@@ -4087,6 +4087,7 @@ finclude (f, fname, op, system_header_p, dirptr)
 
     st_size = 0;
     basep = (U_CHAR *) xmalloc (bsize + 2);
+    fp->buf = basep; /* So it will get freed, on error.  */
     bufp = basep;
 
     for (;;) {
@@ -4100,10 +4101,10 @@ finclude (f, fname, op, system_header_p, dirptr)
       if (bsize == st_size) {  /* Buffer is full! */
          bsize *= 2;
          basep = (U_CHAR *) xrealloc (basep, bsize + 2);
+         fp->buf = basep;
          bufp = basep + st_size;       /* May have moved */
        }
     }
-    fp->buf = basep;
     fp->bufp = fp->buf;
     fp->length = st_size;
   }