diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-08-01 03:16:38 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2009-08-01 03:16:38 +0400 |
commit | 631df8cc01c17307a580d13760cba43800c75b91 (patch) | |
tree | dde9f12b19b70b23669e51c97d38cadec7912b48 /source/blender/freestyle/intern/python/BPy_Iterator.cpp | |
parent | ba9943e4a7a6c671e427c08fc11845168a30e86a (diff) |
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.
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_Iterator.cpp')
-rw-r--r-- | source/blender/freestyle/intern/python/BPy_Iterator.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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; |