@@ -1377,6 +1377,7 @@ array_fromstring(arrayobject *self, PyObject *args) { char *str; Py_ssize_t n; + int copyself; int itemsize = self->ob_descr->itemsize; if (!PyArg_ParseTuple(args, "s#:fromstring", &str, &n)) return NULL; @@ -1392,7 +1393,10 @@ array_fromstring(arrayobject *self, PyObject *args) ((Py_SIZE(self) + n) > PY_SSIZE_T_MAX / itemsize)) { return PyErr_NoMemory(); } + copyself = item == str; PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize); + if (copyself) + str = item; if (item == NULL) { PyErr_NoMemory(); return NULL;