Fixed fd lead in opendir() and set errno correctly if memory is out.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1564 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2002-10-17 19:27:03 +00:00
parent 69b81fcc90
commit b7c42fadf7

View File

@ -34,8 +34,11 @@ opendir(const char *path)
return NULL; return NULL;
/* allocate the memory for the DIR structure */ /* allocate the memory for the DIR structure */
if ((dir = (DIR*)malloc(sizeof(DIR) + BUFFER_SIZE)) == NULL) if ((dir = (DIR*)malloc(sizeof(DIR) + BUFFER_SIZE)) == NULL) {
errno = B_NO_MEMORY;
sys_close(fd);
return NULL; return NULL;
}
dir->fd = fd; dir->fd = fd;