Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-01-09 17:25:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-09 17:25:46 +0400
commitf9c87b86fc03e6239c7be53a20aeec1b735c293d (patch)
tree02d2648afe8af6851f8969c92a2aa1496f4b72e9 /source/blender/python
parent2d526c23dde460de6573bb8795d3490722498387 (diff)
partial fix for [#32581] Mesh properties API does not allow for zeros in byte array
bmesh access allows zero bytes, support still needs adding via RNA.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types_customdata.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c
index fd31f3c40cc..4a8f8d49f35 100644
--- a/source/blender/python/bmesh/bmesh_py_types_customdata.c
+++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c
@@ -981,7 +981,7 @@ PyObject *BPy_BMLayerItem_GetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer)
case CD_PROP_STR:
{
MStringProperty *mstring = value;
- ret = PyBytes_FromStringAndSize(mstring->s, BLI_strnlen(mstring->s, sizeof(mstring->s)));
+ ret = PyBytes_FromStringAndSize(mstring->s, mstring->s_len);
break;
}
case CD_MTEXPOLY:
@@ -1067,13 +1067,17 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
case CD_PROP_STR:
{
MStringProperty *mstring = value;
- const char *tmp_val = PyBytes_AsString(py_value);
- if (UNLIKELY(tmp_val == NULL)) {
+ char *tmp_val;
+ Py_ssize_t tmp_val_len;
+ if (UNLIKELY(PyBytes_AsStringAndSize(py_value, &tmp_val, &tmp_val_len) == -1)) {
PyErr_Format(PyExc_TypeError, "expected bytes, not a %.200s", Py_TYPE(py_value)->tp_name);
ret = -1;
}
else {
- BLI_strncpy(mstring->s, tmp_val, min_ii(PyBytes_Size(py_value), sizeof(mstring->s)));
+ if (tmp_val_len > sizeof(mstring->s))
+ tmp_val_len = sizeof(mstring->s);
+ memcpy(mstring->s, tmp_val, tmp_val_len);
+ mstring->s_len = tmp_val_len;
}
break;
}