Avoid a memory leak pointed out by Lucas C. Villa Real.
authorRob Landley <rob@landley.net>
Thu, 18 May 2006 20:41:43 +0000 (20:41 -0000)
committerRob Landley <rob@landley.net>
Thu, 18 May 2006 20:41:43 +0000 (20:41 -0000)
modutils/modprobe.c

index 2925dd28d1bd73b680d260565ea7e103a866977e..3f68d64ea98d013408b6f9fe90f3630aa9f919ae 100644 (file)
@@ -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 );