summaryrefslogtreecommitdiff
path: root/sysdeps/linux-gnu/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/linux-gnu/proc.c')
-rw-r--r--sysdeps/linux-gnu/proc.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index 953fd86..d17510d 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -242,14 +242,8 @@ process_tasks(pid_t pid, pid_t **ret_tasks, size_t *ret_n)
size_t alloc = 0;
while (1) {
- struct dirent entry;
struct dirent *result;
- if (readdir_r(d, &entry, &result) != 0) {
- fail:
- free(tasks);
- closedir(d);
- return -1;
- }
+ result = readdir(d);
if (result == NULL)
break;
if (result->d_type == DT_DIR && all_digits(result->d_name)) {
@@ -258,8 +252,11 @@ process_tasks(pid_t pid, pid_t **ret_tasks, size_t *ret_n)
alloc = alloc > 0 ? (2 * alloc) : 8;
pid_t *ntasks = realloc(tasks,
sizeof(*tasks) * alloc);
- if (ntasks == NULL)
- goto fail;
+ if (ntasks == NULL) {
+ free(tasks);
+ closedir(d);
+ return -1;
+ }
tasks = ntasks;
}
assert(n < alloc);