summaryrefslogtreecommitdiff
path: root/Modules/_localemodule.c
diff options
context:
space:
mode:
authorKristjan Valur Jonsson <sweskman@gmail.com>2012-05-31 09:37:31 +0000
committerKristjan Valur Jonsson <sweskman@gmail.com>2012-05-31 09:37:31 +0000
commit85634d7a2e4b864c4ca3baa591e9479ffd5a2540 (patch)
treefda37abce087013b6b52f85a19a4ff33c1b13dce /Modules/_localemodule.c
parent56517e5cb91c896024934a520d365d6e275eb1ad (diff)
downloadcpython-git-85634d7a2e4b864c4ca3baa591e9479ffd5a2540.tar.gz
Issue #14909: A number of places were using PyMem_Realloc() apis and
PyObject_GC_Resize() with incorrect error handling. In case of errors, the original object would be leaked. This checkin fixes those cases.
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r--Modules/_localemodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 20c59a4e1a..cc688ba140 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -257,11 +257,12 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
n2 = wcsxfrm(buf, s, n1);
if (n2 >= (size_t)n1) {
/* more space needed */
- buf = PyMem_Realloc(buf, (n2+1)*sizeof(wchar_t));
- if (!buf) {
+ wchar_t * new_buf = PyMem_Realloc(buf, (n2+1)*sizeof(wchar_t));
+ if (!new_buf) {
PyErr_NoMemory();
goto exit;
}
+ buf = new_buf;
n2 = wcsxfrm(buf, s, n2+1);
}
result = PyUnicode_FromWideChar(buf, n2);