static pid_t *
create_pid_table(int *max_pids, int *pids)
{
- pid_t self, *pid_table;
+ pid_t self, *pid_table, *realloc_pid_table;
int pid;
DIR *dir;
struct dirent *de;
continue;
if (*pids == *max_pids)
{
- if (!(pid_table = realloc (pid_table, 2 * *pids * sizeof (pid_t))))
+ if (!(realloc_pid_table = realloc (pid_table, 2 * *pids * sizeof (pid_t))))
{
perror ("realloc");
+ free(pid_table);
exit (1);
}
+ pid_table = realloc_pid_table;
*max_pids *= 2;
}
pid_table[(*pids)++] = pid;
if (argv[1][0] != '/') {
if (asprintf(&fullpath, "/proc/%s/fd/", argv[1]) < 0) {
perror ("asprintf");
+ free(linkpath);
return 1;
}
} else {
if (asprintf(&fullpath, "%s/fd/", argv[1]) < 0) {
perror("asprintf");
+ free(linkpath);
return 1;
}
}
pid_dir = opendir(fullpath);
if (!pid_dir) {
perror("opendir");
+ free(linkpath);
free(fullpath);
return 1;
}