From dd020b4b0415e7fe255d4f0f89dd6305f89c1319 Mon Sep 17 00:00:00 2001 From: banthonywalker Date: Fri, 6 Mar 2015 18:34:57 +0100 Subject: [PATCH] Subject: [PATCH 1/2] fix win32 context memory leak --- lib/context.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/context.c b/lib/context.c index fa62f837..7839afd1 100644 --- a/lib/context.c +++ b/lib/context.c @@ -164,7 +164,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info) #endif if (lws_plat_init_fd_tables(context)) { -#ifndef _WIN32 +#ifdef _WIN32 + for (i = 0; i < FD_HASHTABLE_MODULUS; i++) { + lws_free(context->fd_hashtable[i].wsi); + } +#else lws_free(context->lws_lookup); #endif lws_free(context->fds); @@ -339,7 +343,11 @@ libwebsocket_context_destroy(struct libwebsocket_context *context) lws_ssl_context_destroy(context); lws_free(context->fds); -#ifndef _WIN32 +#ifdef _WIN32 + for (n = 0; n < FD_HASHTABLE_MODULUS; n++) { + lws_free(context->fd_hashtable[n].wsi); + } +#else lws_free(context->lws_lookup); #endif lws_plat_context_late_destroy(context);