mdev: microscopic enhancement, should change nothing
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 8 Jun 2007 16:18:15 +0000 (16:18 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 8 Jun 2007 16:18:15 +0000 (16:18 -0000)
util-linux/mdev.c

index cc729e72a943b158b47ad88b27ca4969fd45d8c9..d1b2684bc60698ac19715cb5d2dee0e4eec01b6c 100644 (file)
@@ -178,17 +178,15 @@ static void make_device(char *path, int delete)
                if (ENABLE_FEATURE_MDEV_CONF) chown(device_name, uid, gid);
        }
        if (command) {
-               int rc;
-               char *s;
-
-               s = xasprintf("MDEV=%s", device_name);
-               putenv(s);
-               rc = system(command);
-               s[4] = 0;
+               /* setenv will leak memory, so use putenv */
+               char *s = xasprintf("MDEV=%s", device_name);
                putenv(s);
+               if (system(command) == -1)
+                       bb_perror_msg_and_die("cannot run %s", command);
+               s[4] = '\0';
+               unsetenv(s);
                free(s);
                free(command);
-               if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
        }
        if (delete) unlink(device_name);
 }