Fix #98973: Renaming Custom Python Properties is Incorrect

PyUnicode_AsUTF8AndSize is used when renaming a custom python property,
this method stores the size of the string without including the null
terminator in the size.

Renaming a custom python property now includes the null terminator when
copying the new string name.

Pull Request: https://projects.blender.org/blender/blender/pulls/107983
This commit is contained in:
guishe
2023-05-16 10:42:46 -06:00
committed by Brecht Van Lommel
parent c1d353c17b
commit 6948a2d613

View File

@@ -261,12 +261,12 @@ static int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *UNUS
name = PyUnicode_AsUTF8AndSize(value, &name_size);
if (name_size >= MAX_IDPROP_NAME) {
if (name_size + 1 >= MAX_IDPROP_NAME) {
PyErr_SetString(PyExc_TypeError, "string length cannot exceed 63 characters!");
return -1;
}
memcpy(self->prop->name, name, name_size);
memcpy(self->prop->name, name, name_size + 1);
return 0;
}