From 631df8cc01c17307a580d13760cba43800c75b91 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Fri, 31 Jul 2009 23:16:38 +0000 Subject: Added boundary checking to Iterator::increment() and Iterator::decrement() to avoid an immediate crash. Now these methods raise a RuntimeError when the iteration is already at the end. --- source/blender/freestyle/intern/python/BPy_Iterator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/freestyle/intern/python') diff --git a/source/blender/freestyle/intern/python/BPy_Iterator.cpp b/source/blender/freestyle/intern/python/BPy_Iterator.cpp index 3356325c92f..1ae58073a67 100644 --- a/source/blender/freestyle/intern/python/BPy_Iterator.cpp +++ b/source/blender/freestyle/intern/python/BPy_Iterator.cpp @@ -209,12 +209,20 @@ PyObject * Iterator_getExactTypeName(BPy_Iterator* self) { PyObject * Iterator_increment(BPy_Iterator* self) { + if (self->it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError , "cannot increment any more"); + return NULL; + } self->it->increment(); Py_RETURN_NONE; } PyObject * Iterator_decrement(BPy_Iterator* self) { + if (self->it->isBegin()) { + PyErr_SetString(PyExc_RuntimeError , "cannot decrement any more"); + return NULL; + } self->it->decrement(); Py_RETURN_NONE; -- cgit v1.2.3