diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-10-18 21:57:33 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-10-18 21:57:33 +0400 |
commit | 6d88769cc2d75d05297d6750334b3bc0e16bee81 (patch) | |
tree | db6fe58539cce9ba214351049b3fc817feb1081b /source/blender/freestyle/intern/python/BPy_Nature.cpp | |
parent | 211e7be58099445af48d5d678566794f39754ec2 (diff) |
Improved error checks in the Freestyle.Nature class.
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Nature.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_Nature.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_Nature.cpp b/source/blender/freestyle/intern/python/BPy_Nature.cpp index 3769271712e..3f6ca273ee8 100644 --- a/source/blender/freestyle/intern/python/BPy_Nature.cpp +++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp @@ -204,10 +204,27 @@ BPy_Nature_bitwise(PyObject *a, int op, PyObject *b) PyErr_SetString(PyExc_TypeError, "operands must be a Nature object"); return NULL; } + if (Py_SIZE(a) != 1) { + stringstream msg; + msg << "operand 1: unexpected Nature byte length: " << Py_SIZE(a); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } + if (Py_SIZE(b) != 1) { + stringstream msg; + msg << "operand 2: unexpected Nature byte length: " << Py_SIZE(b); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1); if (!result) return NULL; - assert(Py_SIZE(a) == 1 && Py_SIZE(b) == 1 && Py_SIZE(result) == 1); + if (Py_SIZE(result) != 1) { + stringstream msg; + msg << "unexpected Nature byte length: " << Py_SIZE(result); + PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + return NULL; + } switch (op) { case '&': result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) & (((PyLongObject *)b)->ob_digit)[0]; |