winpr/thread: don't close invalid file descriptors

In case the file descriptor is -1 don't call close.
This commit is contained in:
Bernhard Miklautz 2015-07-24 14:57:47 +02:00
parent 4250f3f030
commit c3ea07f3d9

View File

@ -504,10 +504,10 @@ void cleanup_handle(void *obj)
WLog_ERR(TAG, "failed to destroy mutex [%d] %s (%d)",
rc, strerror(errno), errno);
if (thread->pipe_fd[0])
if (thread->pipe_fd[0] >= 0)
close(thread->pipe_fd[0]);
if (thread->pipe_fd[1])
if (thread->pipe_fd[1] >= 0)
close(thread->pipe_fd[1]);
if (thread_list && ListDictionary_Contains(thread_list, &thread->thread))