From 8eb1064f4166cc939e2216e560a8e0f0a1ce76ce Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Wed, 29 Jul 2009 00:11:41 +0000 Subject: Implemented a measure to avoid an infinite loop triggered when ChainingIterator::init() and ChainingIterator::traverse() were not properly overloaded in a subclass. --- .../freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/freestyle/intern') diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp index df239793e3e..e6093236901 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp @@ -153,6 +153,10 @@ int ChainingIterator___init__(BPy_ChainingIterator *self, PyObject *args ) } PyObject *ChainingIterator_init( BPy_ChainingIterator *self ) { + if( typeid(*(self->c_it)) == typeid(ChainingIterator) ) { + PyErr_SetString(PyExc_TypeError, "init() method must be overloaded"); + return NULL; + } self->c_it->init(); Py_RETURN_NONE; @@ -164,6 +168,10 @@ PyObject *ChainingIterator_traverse( BPy_ChainingIterator *self, PyObject *args if(!( PyArg_ParseTuple(args, "O!", &AdjacencyIterator_Type, &py_a_it) )) return NULL; + if( typeid(*(self->c_it)) == typeid(ChainingIterator) ) { + PyErr_SetString(PyExc_TypeError, "traverse() method must be overloaded"); + return NULL; + } if( ((BPy_AdjacencyIterator *) py_a_it)->a_it ) self->c_it->traverse(*( ((BPy_AdjacencyIterator *) py_a_it)->a_it )); -- cgit v1.2.3