--- a/lsflib/src/md5recursive.c
+++ b/lsflib/src/md5recursive.c
@@ -30,26 +30,18 @@
}
while ((entry = readdir (directory))) {
- list = (char *)malloc (strlen (root) + 1 + strlen (entry->d_name) + 1);
-
- if (list == NULL) {
- perror ("malloc");
- return;
- }
-
- sprintf (list, "%s/%s", root, entry->d_name);
-
- if (!strcmp (entry->d_name, "."))
+ if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, "..")))
continue;
- if (!strcmp (entry->d_name, ".."))
- continue;
+ list = malloc (strlen (root) + 1 + strlen (entry->d_name) + 1);
+ sprintf (list, "%s/%s", root, entry->d_name);
if (isDir (list)) {
fprintf (stderr, "Directory: %s\n", list);
if (recursive) {
md5recursive (list, recursive);
}
+ free (list);
continue;
}
@@ -60,9 +52,9 @@
for (i = 0; i < 16; i++)
printf ("%02x", value[i]);
printf (" %s\n", list);
+ free (list);
free (value);
}
- free (list);
closedir (directory);
}