diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-04-12 04:26:27 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-04-12 04:26:27 (GMT) |
commit | 8fc8980c96f58a7f06e4e3133735807bd245c658 (patch) | |
tree | 04376ea1928a20c88b506e836ab82cc266cc85ae /Include | |
parent | fe0a41aae425c61364b79c18ca8321dffed3ac40 (diff) | |
download | cpython-8fc8980c96f58a7f06e4e3133735807bd245c658.zip cpython-8fc8980c96f58a7f06e4e3133735807bd245c658.tar.gz cpython-8fc8980c96f58a7f06e4e3133735807bd245c658.tar.bz2 |
Issue #23524: Replace _PyVerify_fd function with calls to _set_thread_local_invalid_parameter_handler.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/fileutils.h | 2 | ||||
-rw-r--r-- | Include/pyport.h | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/Include/fileutils.h b/Include/fileutils.h index 2430c26..b4a683c 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -121,7 +121,7 @@ PyAPI_FUNC(int) _Py_get_blocking(int fd); PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); #endif /* !MS_WINDOWS */ -#if defined _MSC_VER && _MSC_VER >= 1400 +#if defined _MSC_VER && _MSC_VER >= 1400 && _MSC_VER < 1900 /* A routine to check if a file descriptor is valid on Windows. Returns 0 * and sets errno to EBADF if it isn't. This is to avoid Assertions * from various functions in the Windows CRT beginning with diff --git a/Include/pyport.h b/Include/pyport.h index e4b2cf0..82ad718 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -877,4 +877,24 @@ extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); #define PY_LITTLE_ENDIAN 1 #endif +#ifdef Py_BUILD_CORE +/* + * Macros to protect CRT calls against instant termination when passed an + * invalid parameter (issue23524). + */ +#if defined _MSC_VER && _MSC_VER >= 1900 + +extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; +#define _Py_BEGIN_SUPPRESS_IPH { _invalid_parameter_handler _Py_old_handler = \ + _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); +#define _Py_END_SUPPRESS_IPH _set_thread_local_invalid_parameter_handler(_Py_old_handler); } + +#else + +#define _Py_BEGIN_SUPPRESS_IPH +#define _Py_END_SUPPRESS_IPH + +#endif /* _MSC_VER >= 1900 */ +#endif /* Py_BUILD_CORE */ + #endif /* Py_PYPORT_H */ |