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:
Diffstat (limited to 'source/gameengine/Expressions/PyObjectPlus.cpp')
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index 33aa6b8d177..87f776a726e 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -1012,8 +1012,8 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
{
if (PyUnicode_Check(value))
{
- Py_ssize_t val_len;
- char *val = _PyUnicode_AsStringAndSize(value, &val_len);
+ Py_ssize_t val_size;
+ const char *val = _PyUnicode_AsStringAndSize(value, &val_size);
strncpy(ptr, val, attrdef->m_size);
ptr[attrdef->m_size-1] = 0;
}
@@ -1030,7 +1030,7 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
if (PyUnicode_Check(value))
{
Py_ssize_t val_len;
- char *val = _PyUnicode_AsStringAndSize(value, &val_len);
+ const char *val = _PyUnicode_AsStringAndSize(value, &val_len); /* XXX, should be 'const' but we do a silly trick to have a shorter string */
if (attrdef->m_clamp)
{
if (val_len < attrdef->m_imin)
@@ -1042,10 +1042,8 @@ int PyObjectPlus::py_set_attrdef(PyObject *self_py, PyObject *value, const PyAtt
else if (val_len > attrdef->m_imax)
{
// trim the string
- char c = val[attrdef->m_imax];
- val[attrdef->m_imax] = 0;
- *var = val;
- val[attrdef->m_imax] = c;
+ var->SetLength(attrdef->m_imax);
+ memcpy(var->Ptr(), val, attrdef->m_imax - 1);
break;
}
} else if (val_len < attrdef->m_imin || val_len > attrdef->m_imax)