diff --git a/include/kdev-pg-token-stream.h b/include/kdev-pg-token-stream.h --- a/include/kdev-pg-token-stream.h +++ b/include/kdev-pg-token-stream.h @@ -128,22 +128,25 @@ */ inline void rewind(qint64 index) { + Q_ASSERT(0 <= index && index <= size()); mIndex = index; } /** * Returns the token at the specified position in the stream. */ inline T const &at(qint64 index) const { + Q_ASSERT(0 <= index && index < size()); return mTokenBuffer[index]; } /** * Returns the token at the specified position in the stream. */ inline T &at(qint64 index) { + Q_ASSERT(0 <= index && index < size()); return mTokenBuffer[index]; } @@ -184,6 +187,7 @@ */ inline T &curr() { + Q_ASSERT(mIndex < size()); return mTokenBuffer[mIndex]; }