[3.13] gh-140474: Fix memory leak in array.array (GH-140478) (GH-140499)

gh-140474: Fix memory leak in `array.array` (GH-140478)
(cherry picked from commit aa9d0a61d5)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-10-23 14:18:01 +02:00 committed by GitHub
parent 30c2661b6e
commit 640bc258c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -2806,6 +2806,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_SET_SIZE(self, n);
self->allocated = n;
}
else {
PyMem_Free(ustr);
}
}
else { // c == 'w'
Py_ssize_t n = PyUnicode_GET_LENGTH(initial);