浏览代码

Fix opendir problem when statically linked due to a missing
initialization of the mutex field within DIR struct.
When linked dynamically instead, __pthread_mutex_init will
initialize the mutex itself. Without this fix, any call to
readdir will stuck forever trying to acquire the mutex.

Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>

Carmelo Amoroso 17 年之前
父节点
当前提交
d53b49e5f5
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      libc/misc/dirent/opendir.c

+ 1 - 0
libc/misc/dirent/opendir.c

@@ -64,6 +64,7 @@ close_and_ret:
 	if (!(ptr = malloc(sizeof(*ptr))))
 		goto nomem_close_and_ret;
 
+	memset(ptr, '\0', sizeof(DIR));
 	ptr->dd_fd = fd;
 	ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;