remove memory leak in scan_dir()
authorSebastian Stark <stark@ranga.kyb.local>
Tue, 20 May 2008 15:22:00 +0000 (17:22 +0200)
committerSebastian Stark <stark@ranga.kyb.local>
Tue, 20 May 2008 15:22:00 +0000 (17:22 +0200)
the tmp pointer is used only for directory entries. However, it was allocated
unconditionally and was not freed in case of regular files.

adu.c

diff --git a/adu.c b/adu.c
index b311a38..03df3e1 100644 (file)
--- a/adu.c
+++ b/adu.c
@@ -414,8 +414,8 @@ int scan_dir(char *dirname)
                m = s.st_mode;
                if (!S_ISREG(m) && !S_ISDIR(m))
                        continue;
-               tmp = make_message("%s/%s", dirname, entry->d_name);
                if (S_ISDIR(m)) {
+                       tmp = make_message("%s/%s", dirname, entry->d_name);
                        ret = scan_dir(tmp);
                        free(tmp);
                        if (ret < 0)