This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


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

A patch for fts.c


Here is a patch for fts.c.


-- 
H.J. Lu (hjl@gnu.org)
---
Fri Jan  8 07:37:48 1999  H.J. Lu  <hjl@gnu.org>

	* io/fts.c (fts_close): Fix a memory leak.

Index: io/fts.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/io/fts.c,v
retrieving revision 1.1.1.7
diff -u -p -r1.1.1.7 fts.c
--- fts.c	1998/09/11 13:50:04	1.1.1.7
+++ fts.c	1999/01/08 20:36:45
@@ -231,6 +231,7 @@ fts_close(sp)
 {
 	register FTSENT *freep, *p;
 	int saved_errno;
+	int retval;
 
 	/*
 	 * This still works if we haven't read anything -- the dummy structure
@@ -259,15 +260,18 @@ fts_close(sp)
 		(void)__close(sp->fts_rfd);
 	}
 
-	/* Free up the stream pointer. */
-	free(sp);
-
 	/* Set errno and return. */
 	if (!ISSET(FTS_NOCHDIR) && saved_errno) {
 		__set_errno (saved_errno);
-		return (-1);
+		retval = -1;
 	}
-	return (0);
+	else
+		retval = 0;
+
+	/* Free up the stream pointer. */
+	free(sp);
+
+	return retval; 
 }
 
 /*


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