浏览代码

fix bug 1012 as noted by moschny

Eric Andersen 19 年之前
父节点
当前提交
285768c7f0
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      libc/misc/dirent/readdir_r.c

+ 1 - 1
libc/misc/dirent/readdir_r.c

@@ -34,7 +34,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
 		bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max);
 		bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max);
 		if (bytes <= 0) {
 		if (bytes <= 0) {
 		    *result = NULL;
 		    *result = NULL;
-		    ret = errno;
+		    ret = (bytes==0)? 0 : errno;
 		    goto all_done;
 		    goto all_done;
 		}
 		}
 		dir->dd_size = bytes;
 		dir->dd_size = bytes;