From 6eec552ea4420217d65d4ea9b5dc14217f93b2ad Mon Sep 17 00:00:00 2001 From: "nullable.type" Date: Sat, 27 Oct 2012 14:04:41 +0200 Subject: [PATCH 1/4] Added declaration to avoid warning C4115 (named type definition in parentheses) issued by Visual Studio 2012. --- mongoose.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mongoose.c b/mongoose.c index e124135f..ccaf5e22 100644 --- a/mongoose.c +++ b/mongoose.c @@ -146,6 +146,8 @@ static int pthread_mutex_lock(pthread_mutex_t *); static int pthread_mutex_unlock(pthread_mutex_t *); static void to_unicode(const char *path, wchar_t *wbuf, size_t wbuf_len); + +struct file; static char *mg_fgets(char *buf, size_t size, struct file *filep, char **p); #if defined(HAVE_STDINT) From 73a845a327c24e1c0ee99427bada7c0b4bd33427 Mon Sep 17 00:00:00 2001 From: "nullable.type" Date: Sat, 27 Oct 2012 14:07:06 +0200 Subject: [PATCH 2/4] Suppress warning C4204 (non-constant aggregate initializer) issued by Visual Studio 2012 due to missing C99 support. --- mongoose.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mongoose.c b/mongoose.c index ccaf5e22..c3edd4a8 100644 --- a/mongoose.c +++ b/mongoose.c @@ -29,6 +29,10 @@ #define __STDC_LIMIT_MACROS // C++ wants that for INT64_MAX #endif +#if defined (_MSC_VER) +#pragma warning (disable : 4204) // non-constant aggregate initializer: issued due to missing C99 support +#endif + // Disable WIN32_LEAN_AND_MEAN. // This makes windows.h always include winsock2.h #ifdef WIN32_LEAN_AND_MEAN From c5ba6016aa714fcb13585a5690a1461bdf39e8f4 Mon Sep 17 00:00:00 2001 From: "nullable.type" Date: Sat, 27 Oct 2012 14:09:26 +0200 Subject: [PATCH 3/4] Suppress warning C4127 (conditional expression is constant) issued by Visual Studio 2012 introduced by FD_SET(..) which is using the do-while(0) trick. --- mongoose.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mongoose.c b/mongoose.c index c3edd4a8..9ed3c638 100644 --- a/mongoose.c +++ b/mongoose.c @@ -30,6 +30,7 @@ #endif #if defined (_MSC_VER) +#pragma warning (disable : 4127) // conditional expression is constant: introduced by FD_SET(..) #pragma warning (disable : 4204) // non-constant aggregate initializer: issued due to missing C99 support #endif From eb92b5f1b3f1c513fb70cef15d5be6f8d82d2f3d Mon Sep 17 00:00:00 2001 From: "nullable.type" Date: Fri, 2 Nov 2012 22:52:47 +0100 Subject: [PATCH 4/4] Avoid memory leaks if duplicate options are passed. --- mongoose.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mongoose.c b/mongoose.c index 9ed3c638..acfb3787 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4976,6 +4976,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data, } if (ctx->config[i] != NULL) { cry(fc(ctx), "warning: %s: duplicate option", name); + free(ctx->config[i]); } ctx->config[i] = mg_strdup(value); DEBUG_TRACE(("[%s] -> [%s]", name, value));