summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyeongsik Min <hyeongsik.min@samsung.com>2016-12-27 16:25:19 +0900
committerHyeongsik Min <hyeongsik.min@samsung.com>2016-12-27 20:24:18 +0900
commit6372bf3677c216ce8dd4dad90c51a6f2bff17f12 (patch)
tree5a5570744617932eb0f37934f05862fae938ecbc
parent004a8b4fd3e6c6c592aba8dbafde5516c7bc1bef (diff)
downloadltrace-accepted/tizen/unified/20170309.040228.tar.gz
ltrace-accepted/tizen/unified/20170309.040228.tar.bz2
ltrace-accepted/tizen/unified/20170309.040228.zip
Change-Id: I1a6c75d8a2f64e58a4c81724e2c3b0568b581a7b Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
-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);