diff options
author | Kristjan Valur Jonsson <sweskman@gmail.com> | 2012-05-31 09:37:31 +0000 |
---|---|---|
committer | Kristjan Valur Jonsson <sweskman@gmail.com> | 2012-05-31 09:37:31 +0000 |
commit | 85634d7a2e4b864c4ca3baa591e9479ffd5a2540 (patch) | |
tree | fda37abce087013b6b52f85a19a4ff33c1b13dce /Modules/unicodedata.c | |
parent | Make parameterized tests in email less hackish. (diff) | |
download | cpython-85634d7a2e4b864c4ca3baa591e9479ffd5a2540.tar.gz cpython-85634d7a2e4b864c4ca3baa591e9479ffd5a2540.tar.bz2 cpython-85634d7a2e4b864c4ca3baa591e9479ffd5a2540.zip |
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/unicodedata.c')
-rw-r--r-- | Modules/unicodedata.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index ed79165770b..5c982f5c293 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -526,13 +526,16 @@ nfd_nfkd(PyObject *self, PyObject *input, int k) /* Hangul Decomposition adds three characters in a single step, so we need atleast that much room. */ if (space < 3) { + Py_UCS4 *new_output; osize += 10; space += 10; - output = PyMem_Realloc(output, osize*sizeof(Py_UCS4)); - if (output == NULL) { + new_output = PyMem_Realloc(output, osize*sizeof(Py_UCS4)); + if (new_output == NULL) { + PyMem_Free(output); PyErr_NoMemory(); return NULL; } + output = new_output; } /* Hangul Decomposition. */ if (SBase <= code && code < (SBase+SCount)) { |