From 2e116b2eeea5f47ca26458b1962783baced2784c Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 9 Dec 2015 08:07:09 +0100 Subject: fix readdir_r returns success code while it in fact failed Taken from Freetz.org. Signed-off-by: Leonid Lisovskiy Signed-off-by: Waldemar Brodkorb --- libc/misc/dirent/readdir_r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c index 7cdc0aba1..5beebfed0 100644 --- a/libc/misc/dirent/readdir_r.c +++ b/libc/misc/dirent/readdir_r.c @@ -27,7 +27,6 @@ int __READDIR_R(DIR *dir, __DIRENT_TYPE *entry, __DIRENT_TYPE **result) __set_errno(EBADF); return(EBADF); } - de = NULL; __UCLIBC_MUTEX_LOCK(dir->dd_lock); @@ -36,6 +35,7 @@ int __READDIR_R(DIR *dir, __DIRENT_TYPE *entry, __DIRENT_TYPE **result) /* read dir->dd_max bytes of directory entries. */ bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max); if (bytes <= 0) { + de = NULL; *result = NULL; ret = (bytes==0)? 0 : errno; goto all_done; -- cgit v1.2.3