diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-12-01 21:51:04 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-12-01 21:51:04 (GMT) |
commit | d728871ee170604e18dd8e0bf1b28b6520a5b809 (patch) | |
tree | 826b4afa90b41c4033813778be9d571827862acf /Modules | |
parent | 7072f74dc8bea03490ab09af3ee5a902bdc6f284 (diff) | |
download | cpython-d728871ee170604e18dd8e0bf1b28b6520a5b809.zip cpython-d728871ee170604e18dd8e0bf1b28b6520a5b809.tar.gz cpython-d728871ee170604e18dd8e0bf1b28b6520a5b809.tar.bz2 |
#7419: Fix a crash on Windows in locale.setlocale() when the category
is outside the allowed range.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_localemodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 94d0014..f1f4abf 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -163,6 +163,14 @@ PyLocale_setlocale(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, "i|z:setlocale", &category, &locale)) return NULL; +#if defined(MS_WINDOWS) + if (category < LC_MIN || category > LC_MAX) + { + PyErr_SetString(Error, "invalid locale category"); + return NULL; + } +#endif + if (locale) { /* set locale */ result = setlocale(category, locale); |