Skip to content

Commit 11cd907

Browse files
erlend-aaslandaisk
authored andcommitted
pythongh-114569: Use PyMem_* APIs for non-PyObjects in unicodeobject.c (python#114690)
1 parent 73e06df commit 11cd907

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Objects/unicodeobject.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
996996
new_size = (struct_size + (length + 1) * char_size);
997997

998998
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
999-
PyObject_Free(_PyUnicode_UTF8(unicode));
999+
PyMem_Free(_PyUnicode_UTF8(unicode));
10001000
_PyUnicode_UTF8(unicode) = NULL;
10011001
_PyUnicode_UTF8_LENGTH(unicode) = 0;
10021002
}
@@ -1049,7 +1049,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
10491049

10501050
if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode))
10511051
{
1052-
PyObject_Free(_PyUnicode_UTF8(unicode));
1052+
PyMem_Free(_PyUnicode_UTF8(unicode));
10531053
_PyUnicode_UTF8(unicode) = NULL;
10541054
_PyUnicode_UTF8_LENGTH(unicode) = 0;
10551055
}
@@ -1590,10 +1590,10 @@ unicode_dealloc(PyObject *unicode)
15901590
return;
15911591
}
15921592
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
1593-
PyObject_Free(_PyUnicode_UTF8(unicode));
1593+
PyMem_Free(_PyUnicode_UTF8(unicode));
15941594
}
15951595
if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode)) {
1596-
PyObject_Free(_PyUnicode_DATA_ANY(unicode));
1596+
PyMem_Free(_PyUnicode_DATA_ANY(unicode));
15971597
}
15981598

15991599
Py_TYPE(unicode)->tp_free(unicode);
@@ -5203,7 +5203,7 @@ unicode_fill_utf8(PyObject *unicode)
52035203
PyBytes_AS_STRING(writer.buffer);
52045204
Py_ssize_t len = end - start;
52055205

5206-
char *cache = PyObject_Malloc(len + 1);
5206+
char *cache = PyMem_Malloc(len + 1);
52075207
if (cache == NULL) {
52085208
_PyBytesWriter_Dealloc(&writer);
52095209
PyErr_NoMemory();
@@ -14674,7 +14674,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode)
1467414674
PyErr_NoMemory();
1467514675
goto onError;
1467614676
}
14677-
data = PyObject_Malloc((length + 1) * char_size);
14677+
data = PyMem_Malloc((length + 1) * char_size);
1467814678
if (data == NULL) {
1467914679
PyErr_NoMemory();
1468014680
goto onError;

0 commit comments

Comments
 (0)