server: Avoid leaking file descriptor on error in create_file_for_fd.
This commit is contained in:
parent
609d43e408
commit
3d3c92782a
|
@ -120,11 +120,16 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari
|
|||
if (fstat( fd, &st ) == -1)
|
||||
{
|
||||
file_set_error();
|
||||
close( fd );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((file = alloc_object( &file_ops )))
|
||||
if (!(file = alloc_object( &file_ops )))
|
||||
{
|
||||
close( fd );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
file->mode = st.st_mode;
|
||||
file->access = default_fd_map_access( &file->obj, access );
|
||||
if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj,
|
||||
|
@ -134,7 +139,6 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari
|
|||
return NULL;
|
||||
}
|
||||
allow_fd_caching( file->fd );
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue