A bug fix from Vladimir for a memory leak I stupidly
authorEric Andersen <andersen@codepoet.org>
Mon, 7 May 2001 22:45:06 +0000 (22:45 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 7 May 2001 22:45:06 +0000 (22:45 -0000)
added to which.c.

findutils/which.c
which.c

index 1e5e9eed5569bee54775b9b401e6a1f4c1312eb6..b2acd78def36ed40c5f065d98ef1596a30b1bd3e 100644 (file)
@@ -54,8 +54,7 @@ extern int which_main(int argc, char **argv)
                found = 0;
                for (i = 0; i < count; i++) {
                        char *buf;
-                       buf = concat_path_file(buf, path_n);
-                       buf = concat_path_file(buf, *argv);
+                       buf = concat_path_file(path_n, *argv);
                        if (stat (buf, &filestat) == 0
                            && filestat.st_mode & S_IXUSR)
                        {
@@ -63,6 +62,7 @@ extern int which_main(int argc, char **argv)
                                found = 1;
                                break;
                        }
+                       free(buf);
                        path_n += (strlen(path_n) + 1);
                }
                if (!found)
diff --git a/which.c b/which.c
index 1e5e9eed5569bee54775b9b401e6a1f4c1312eb6..b2acd78def36ed40c5f065d98ef1596a30b1bd3e 100644 (file)
--- a/which.c
+++ b/which.c
@@ -54,8 +54,7 @@ extern int which_main(int argc, char **argv)
                found = 0;
                for (i = 0; i < count; i++) {
                        char *buf;
-                       buf = concat_path_file(buf, path_n);
-                       buf = concat_path_file(buf, *argv);
+                       buf = concat_path_file(path_n, *argv);
                        if (stat (buf, &filestat) == 0
                            && filestat.st_mode & S_IXUSR)
                        {
@@ -63,6 +62,7 @@ extern int which_main(int argc, char **argv)
                                found = 1;
                                break;
                        }
+                       free(buf);
                        path_n += (strlen(path_n) + 1);
                }
                if (!found)