From 39ca621987e1d1542cec76b8785aa15ea26e225d Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sat, 22 Sep 2012 03:49:52 +0200 Subject: [PATCH] windows: don't blow up when an invalid FD is used --- src/win/core.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/win/core.c b/src/win/core.c index 79fb655c..5b47c202 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "uv.h" @@ -40,10 +41,21 @@ static uv_once_t uv_init_guard_ = UV_ONCE_INIT; static uv_once_t uv_default_loop_init_guard_ = UV_ONCE_INIT; +static void uv__crt_invalid_parameter_handler(const wchar_t* expression, + const wchar_t* function, const wchar_t * file, unsigned int line, + uintptr_t reserved) { + /* No-op. */ +} + + static void uv_init(void) { /* Tell Windows that we will handle critical errors. */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX); + SEM_NOOPENFILEERRORBOX); + + /* Tell the CRT to not exit the application when an invalid parameter is */ + /* passed. The main issue is that invalid FDs will trigger this behavior. */ + _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler); /* Fetch winapi function pointers. This must be done first because other */ /* intialization code might need these function pointers to be loaded. */