Commit 55f6503d authored by Mark Hammond's avatar Mark Hammond

Fix [ 776721 ] locale.setlocale() leaks

Our saved locale was not being freed.  Also check correct variable for
NULL.
parent c183eab9
...@@ -181,7 +181,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args) ...@@ -181,7 +181,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
return NULL; return NULL;
} }
result_object = PyString_FromString(result); result_object = PyString_FromString(result);
if (!result) if (!result_object)
return NULL; return NULL;
/* record changes to LC_NUMERIC */ /* record changes to LC_NUMERIC */
if (category == LC_NUMERIC || category == LC_ALL) { if (category == LC_NUMERIC || category == LC_ALL) {
...@@ -199,6 +199,8 @@ PyLocale_setlocale(PyObject* self, PyObject* args) ...@@ -199,6 +199,8 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
thousands_sep = PyString_FromString(lc->thousands_sep); thousands_sep = PyString_FromString(lc->thousands_sep);
Py_XDECREF(decimal_point); Py_XDECREF(decimal_point);
decimal_point = PyString_FromString(lc->decimal_point); decimal_point = PyString_FromString(lc->decimal_point);
if (saved_numeric)
free(saved_numeric);
saved_numeric = strdup(locale); saved_numeric = strdup(locale);
/* restore to "C" */ /* restore to "C" */
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment