]> git.tue.mpg.de Git - adu.git/commitdiff
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 b311a386690de22071921950cb7a35b29d3d3b2f..03df3e1625984fff168dceaf32b7f6981b1cb05f 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)