This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Memory leaks - patch2


Hi,

The following patch fixes some more memory leaks. I did not file any PRs
to track these leaks (so these are not reported). Let me know if I need
to open one.

Bootstrapped and regtested on powerpc64-linux. No new regressions.

Thanks,

Uttam

========================================================
2006-02-17  Uttam Pawar  <uttamp@us.ibm.com>

        * mkdeps.c (deps_restore): Free buf pointer.

Index: libcpp/mkdeps.c
===================================================================
*** libcpp/mkdeps.c     (revision 111144)
--- libcpp/mkdeps.c     (working copy)
*************** deps_restore (struct deps *deps, FILE *f
*** 385,405 ****

    /* Number of dependences.  */
    if (fread (&count, 1, sizeof (count), fd) != sizeof (count))
!     return -1;

    /* The length of each dependence string, followed by the string.  */
    for (i = 0; i < count; i++)
      {
        /* Read in # bytes in string.  */
        if (fread (&num_to_read, 1, sizeof (size_t), fd) != sizeof (size_t))
!       return -1;
        if (buf_size < num_to_read + 1)
        {
          buf_size = num_to_read + 1 + 127;
          buf = XRESIZEVEC (char, buf, buf_size);
        }
        if (fread (buf, 1, num_to_read, fd) != num_to_read)
!       return -1;
        buf[num_to_read] = '\0';

        /* Generate makefile dependencies from .pch if -nopch-deps.  */
--- 385,414 ----

    /* Number of dependences.  */
    if (fread (&count, 1, sizeof (count), fd) != sizeof (count))
!     {
!       free (buf);
!       return -1;
!     }

    /* The length of each dependence string, followed by the string.  */
    for (i = 0; i < count; i++)
      {
        /* Read in # bytes in string.  */
        if (fread (&num_to_read, 1, sizeof (size_t), fd) != sizeof (size_t))
!         {
!           free (buf);
!           return -1;
!         }
        if (buf_size < num_to_read + 1)
        {
          buf_size = num_to_read + 1 + 127;
          buf = XRESIZEVEC (char, buf, buf_size);
        }
        if (fread (buf, 1, num_to_read, fd) != num_to_read)
!         {
!           free (buf);
!           return -1;
!         }
        buf[num_to_read] = '\0';

        /* Generate makefile dependencies from .pch if -nopch-deps.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]