summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2003-07-24 14:15:07 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2003-07-24 14:15:07 (GMT)
commit9a71475e9e2e2532819ccacc8d2a6e53fd01a9d2 (patch)
tree1f5c9f293f9df1f005fce7f9e7e95f634a7f4046
parent175ddb5b30f742d47f5567cea106934cc125138d (diff)
downloadcpython-9a71475e9e2e2532819ccacc8d2a6e53fd01a9d2.zip
cpython-9a71475e9e2e2532819ccacc8d2a6e53fd01a9d2.tar.gz
cpython-9a71475e9e2e2532819ccacc8d2a6e53fd01a9d2.tar.bz2
Fix [ 776721 ] locale.setlocale() leaks
Our saved locale was not being freed. Also check correct variable for NULL.
-rw-r--r--Modules/_localemodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 840f838..263e881 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -181,7 +181,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
return NULL;
}
result_object = PyString_FromString(result);
- if (!result)
+ if (!result_object)
return NULL;
/* record changes to LC_NUMERIC */
if (category == LC_NUMERIC || category == LC_ALL) {
@@ -199,6 +199,8 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
thousands_sep = PyString_FromString(lc->thousands_sep);
Py_XDECREF(decimal_point);
decimal_point = PyString_FromString(lc->decimal_point);
+ if (saved_numeric)
+ free(saved_numeric);
saved_numeric = strdup(locale);
/* restore to "C" */
setlocale(LC_NUMERIC, "C");