From 69d7bcdf3965a13891493327666bfb7f07c1015f Mon Sep 17 00:00:00 2001 From: landley Date: Thu, 18 May 2006 20:41:43 +0000 Subject: Avoid a memory leak pointed out by Lucas C. Villa Real. git-svn-id: svn://busybox.net/trunk/busybox@15107 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- modutils/modprobe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'modutils/modprobe.c') diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 2925dd28d..3f68d64ea 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c @@ -388,15 +388,14 @@ static struct dep_t *build_dep ( void ) } 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 ); -- cgit v1.2.3-55-g6feb