mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Fix [ 776721 ] locale.setlocale() leaks
Our saved locale was not being freed. Also check correct variable for NULL.
This commit is contained in:
parent
175ddb5b30
commit
9a71475e9e
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||||
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");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue