This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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 leak in opendir()


Hi,

please have a look at the attached patch.  Maybe it is beneficial to allocate
the dirp and dirp->dd_buf at once?

Have a nice day!

2010-08-24  Sebastian Huber <sebastian.huber@embedded-brains.de>

	* libc/posix/opendir.c: Added missing memory free.

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Index: libc/posix/opendir.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/opendir.c,v
retrieving revision 1.4
diff -u -r1.4 opendir.c
--- libc/posix/opendir.c	6 Jun 2003 19:57:51 -0000	1.4
+++ libc/posix/opendir.c	25 Aug 2010 09:00:09 -0000
@@ -74,6 +74,7 @@
 	dirp->dd_len = 512;
 
 	if (dirp->dd_buf == NULL) {
+		free(dirp);
 		close (fd);
 		return NULL;
 	}

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