svn commit: trunk/busybox/modutils

landley at busybox.net landley at busybox.net
Thu May 18 20:41:45 UTC 2006


Author: landley
Date: 2006-05-18 13:41:43 -0700 (Thu, 18 May 2006)
New Revision: 15107

Log:
Avoid a memory leak pointed out by Lucas C. Villa Real.


Modified:
   trunk/busybox/modutils/modprobe.c


Changeset:
Modified: trunk/busybox/modutils/modprobe.c
===================================================================
--- trunk/busybox/modutils/modprobe.c	2006-05-18 17:36:17 UTC (rev 15106)
+++ trunk/busybox/modutils/modprobe.c	2006-05-18 20:41:43 UTC (rev 15107)
@@ -388,15 +388,14 @@
 	}
 
 	filename = bb_xasprintf("/lib/modules/%s/modules.dep", un.release );
-
-	if (( fd = open ( filename, O_RDONLY )) < 0 ) {
-
+	fd = open ( filename, O_RDONLY );
+	if (ENABLE_FEATURE_CLEAN_UP) free(filename);
+	if (fd < 0) {
 		/* Ok, that didn't work.  Fall back to looking in /lib/modules */
 		if (( fd = open ( "/lib/modules/modules.dep", O_RDONLY )) < 0 ) {
 			return 0;
 		}
 	}
-	free(filename);
 
 	while ( reads ( fd, buffer, sizeof( buffer ))) {
 		int l = strlen ( buffer );




More information about the busybox-cvs mailing list