Commit 3d3c9278 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

server: Avoid leaking file descriptor on error in create_file_for_fd.

parent 609d43e4
...@@ -120,21 +120,25 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari ...@@ -120,21 +120,25 @@ struct file *create_file_for_fd( int fd, unsigned int access, unsigned int shari
if (fstat( fd, &st ) == -1) if (fstat( fd, &st ) == -1)
{ {
file_set_error(); file_set_error();
close( fd );
return NULL; return NULL;
} }
if ((file = alloc_object( &file_ops ))) if (!(file = alloc_object( &file_ops )))
{ {
file->mode = st.st_mode; close( fd );
file->access = default_fd_map_access( &file->obj, access ); return NULL;
if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj, }
FILE_SYNCHRONOUS_IO_NONALERT )))
{ file->mode = st.st_mode;
release_object( file ); file->access = default_fd_map_access( &file->obj, access );
return NULL; if (!(file->fd = create_anonymous_fd( &file_fd_ops, fd, &file->obj,
} FILE_SYNCHRONOUS_IO_NONALERT )))
allow_fd_caching( file->fd ); {
release_object( file );
return NULL;
} }
allow_fd_caching( file->fd );
return file; return file;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment