bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memory leak & patch


From: Kenneth Lorber
Subject: memory leak & patch
Date: Wed, 11 Jun 2003 12:22:17 -0400 (EDT)

This fixes a leak in xresolvepath.

Share and Enjoy,
keni

Index: filesubr.c
===================================================================
RCS file: /cvs/ccvs/src/filesubr.c,v
retrieving revision 1.66
diff -c -r1.66 filesubr.c
*** filesubr.c  9 Jun 2003 20:31:12 -0000       1.66
--- filesubr.c  11 Jun 2003 16:14:54 -0000
***************
*** 927,938 ****
  
      owd = xgetwd();
      if ( CVS_CHDIR ( path ) < 0)
        error ( 1, errno, "cannot chdir to %s", path );
      if ( ( hardpath = xgetwd() ) == NULL )
        error (1, errno, "cannot readlink %s", hardpath);
      if ( CVS_CHDIR ( owd ) < 0)
        error ( 1, errno, "cannot chdir to %s", owd );
! 
      return hardpath;
  }
  
--- 927,948 ----
  
      owd = xgetwd();
      if ( CVS_CHDIR ( path ) < 0)
+     {
+       if (owd) free (owd);
        error ( 1, errno, "cannot chdir to %s", path );
+     }
      if ( ( hardpath = xgetwd() ) == NULL )
+     {
+       if (owd) free (owd);
        error (1, errno, "cannot readlink %s", hardpath);
+     }
      if ( CVS_CHDIR ( owd ) < 0)
+     {
+       if (owd) free (owd);
+       free (hardpath);
        error ( 1, errno, "cannot chdir to %s", owd );
!     }
!     free (owd);
      return hardpath;
  }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]