mirror of
https://github.com/python/cpython.git
synced 2026-10-28 18:35:21 +08:00
[3.14] gh-159739: Preserve the normalization buffer on allocation failure (GH-159755) (#159933)
Save the original buffer before calling PyMem_Resize(), which overwrites its first argument even on failure.
(cherry picked from commit c38d75ce32)
This commit is contained in:
1 parent
20c33c1a66
commit
4147bccdf2
2 files changed
+3
-3
No files matched your search
@@ -0,0 +1 @@
|
||||
Fix a memory leak when Unicode normalization cannot grow its temporary buffer.
|
||||
@@ -716,9 +716,8 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
|
||||
}
|
||||
|
||||
if (run_length > sortbuflen) {
|
||||
Py_UCS4 *new_sortbuf = PyMem_Resize(sortbuf,
|
||||
Py_UCS4,
|
||||
run_length);
|
||||
Py_UCS4 *new_sortbuf = sortbuf;
|
||||
PyMem_Resize(new_sortbuf, Py_UCS4, run_length);
|
||||
if (new_sortbuf == NULL) {
|
||||
PyErr_NoMemory();
|
||||
PyMem_Free(sortbuf);
|
||||
|
||||
Reference in new issue
Block a user