mnt_table_parse_dir in libmount/src/tab_parse.c calls
scandir, and then opendir. When the latter one, opendir is failed,
buffers allocated in scandir are not released.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
#else
static int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
{
- int n = 0, i;
+ int n = 0, i, r = 0;
DIR *dir = NULL;
struct dirent **namelist = NULL;
/* let use "at" functions rather than play crazy games with paths... */
dir = opendir(dirname);
- if (!dir)
- return -errno;
+ if (!dir) {
+ r = -errno;
+ goto out;
+ }
for (i = 0; i < n; i++) {
struct dirent *d = namelist[i];
}
}
+out:
for (i = 0; i < n; i++)
free(namelist[i]);
free(namelist);
if (dir)
closedir(dir);
- return 0;
+ return r;
}
#endif