libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 36ee90baf94a8fd9b6189f153676acf907562c4c
parent 46a4adb3a2abf2666eaa5586884ac543ec2e283d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 21 Dec 2010 14:18:48 +0000

leaks

Diffstat:
Msrc/daemon/daemon.c | 32+++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -773,15 +773,12 @@ create_thread (pthread_t * thread, if (daemon->thread_stack_size != 0) { - if ( (0 != (ret = pthread_attr_init (&attr))) || - (0 != (ret = pthread_attr_setstacksize (&attr, daemon->thread_stack_size))) ) + if (0 != (ret = pthread_attr_init (&attr))) + goto ERR; + if (0 != (ret = pthread_attr_setstacksize (&attr, daemon->thread_stack_size))) { -#if HAVE_MESSAGES - MHD_DLOG (daemon, - "Failed to set thread stack size\n"); -#endif - errno = EINVAL; - return ret; + pthread_attr_destroy (&attr); + goto ERR; } pattr = &attr; } @@ -791,9 +788,16 @@ create_thread (pthread_t * thread, } ret = pthread_create (thread, pattr, start_routine, arg); - if (pattr != NULL) + if (daemon->thread_stack_size != 0) pthread_attr_destroy (&attr); return ret; + ERR: +#if HAVE_MESSAGES + MHD_DLOG (daemon, + "Failed to set thread stack size\n"); +#endif + errno = EINVAL; + return ret; } @@ -1760,6 +1764,8 @@ MHD_start_daemon_va (unsigned int options, MHD_DLOG (retVal, "MHD poll support only works with MHD_USE_THREAD_PER_CONNECTION\n"); #endif + free (retVal->nnc); + pthread_mutex_destroy (&retVal->nnc_lock); free (retVal); return NULL; } @@ -1945,6 +1951,10 @@ MHD_start_daemon_va (unsigned int options, "Failed to initialize TLS support\n"); #endif CLOSE (socket_fd); +#ifdef DAUTH_SUPPORT + pthread_mutex_destroy (&retVal->nnc_lock); + free (retVal->nnc); +#endif pthread_mutex_destroy (&retVal->per_ip_connection_mutex); free (retVal); return NULL; @@ -1961,6 +1971,10 @@ MHD_start_daemon_va (unsigned int options, "Failed to create listen thread: %s\n", STRERROR (res_thread_create)); #endif +#ifdef DAUTH_SUPPORT + pthread_mutex_destroy (&retVal->nnc_lock); + free (retVal->nnc); +#endif pthread_mutex_destroy (&retVal->per_ip_connection_mutex); free (retVal); CLOSE (socket_fd);