Skip to content

Commit bc623ad

Browse files
committed
pythongh-116738: correct Py_UCS4 access and mem allocation
1 parent 284ea3e commit bc623ad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/arraymodule.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ w_getitem(arrayobject *ap, Py_ssize_t i)
808808
if (array_get_item(ap, i, array_load_Py_UCS4, &x, sizeof(Py_UCS4))) {
809809
return NULL;
810810
}
811-
return PyUnicode_FromOrdinal(((Py_UCS4 *) ap->ob_item)[i]);
811+
return PyUnicode_FromOrdinal(x);
812812
}
813813

814814
static int
@@ -3541,11 +3541,11 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
35413541

35423542
arrayobject *self = (arrayobject *)a;
35433543
#ifdef Py_GIL_DISABLED
3544-
if (array_resize(self, sizeof(wchar_t) * n, false)) {
3544+
if (array_resize(self, sizeof(Py_UCS4) * n, false)) {
35453545
Py_DECREF(a);
35463546
return NULL;
35473547
}
3548-
memcpy(self->ob_item, ustr, sizeof(wchar_t) * n);
3548+
memcpy(self->ob_item, ustr, sizeof(Py_UCS4) * n);
35493549
#else
35503550
// self->ob_item may be NULL but it is safe.
35513551
self->ob_item = (char *)ustr;

0 commit comments

Comments
 (0)