Merge pull request #330 from kaleb-himes/CID-66007-coverity

avoid dereference of null pointer if args is null
This commit is contained in:
dgarske
2016-03-02 18:22:07 -08:00

View File

@@ -834,6 +834,9 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
{
SOCKADDR_IN_T client;
socklen_t client_len = sizeof(client);
tcp_ready* ready = NULL;
(void) ready; /* Account for case when "ready" is not used */
if (udp) {
udp_accept(sockfd, clientfd, useAnyAddr, port, args);
@@ -845,8 +848,8 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
/* signal ready to tcp_accept */
{
tcp_ready* ready = args->signal;
if (args)
ready = args->signal;
if (ready) {
pthread_mutex_lock(&ready->mutex);
ready->ready = 1;
@@ -854,18 +857,21 @@ static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
pthread_cond_signal(&ready->cond);
pthread_mutex_unlock(&ready->mutex);
}
}
#elif defined (WOLFSSL_TIRTOS)
/* Need mutex? */
tcp_ready* ready = args->signal;
ready->ready = 1;
ready->port = port;
if (args)
ready = args->signal;
if (ready) {
ready->ready = 1;
ready->port = port;
}
#endif
if (ready_file) {
#ifndef NO_FILESYSTEM
FILE* srf = NULL;
tcp_ready* ready = args ? args->signal : NULL;
if (args)
ready = args->signal;
if (ready) {
srf = fopen(ready->srfName, "w");