Revision: 23922
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23922
Author:   kjym3
Date:     2009-10-18 19:57:33 +0200 (Sun, 18 Oct 2009)

Log Message:
-----------
Improved error checks in the Freestyle.Nature class.

Modified Paths:
--------------
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp
   2009-10-18 17:41:42 UTC (rev 23921)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp
   2009-10-18 17:57:33 UTC (rev 23922)
@@ -204,10 +204,24 @@
                PyErr_SetString(PyExc_TypeError, "operands must be a Nature 
object");
                return NULL;
        }
+       if (Py_SIZE(a) != 1) {
+               string msg("operand 1: unexpected Nature byte length: " + 
Py_SIZE(a));
+               PyErr_SetString(PyExc_TypeError, msg.c_str());
+               return NULL;
+       }
+       if (Py_SIZE(b) != 1) {
+               string msg("operand 2: unexpected Nature byte length: " + 
Py_SIZE(b));
+               PyErr_SetString(PyExc_TypeError, msg.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) {
+               string msg("unexpected Nature byte length: " + Py_SIZE(result));
+               PyErr_SetString(PyExc_TypeError, msg.c_str());
+               return NULL;
+       }
        switch (op) {
        case '&':
                result->i.ob_digit[0] = (((PyLongObject *)a)->ob_digit[0]) & 
(((PyLongObject *)b)->ob_digit)[0];


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to