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,22 +187,25 @@ */ inline T &curr() { + Q_ASSERT(mIndex < size()); return mTokenBuffer[mIndex]; } /** * Last token in the stream. */ inline T &back() { + Q_ASSERT(!mTokenBuffer.empty()); return mTokenBuffer.back(); } /** * First token in the stream. */ inline T &front() { + Q_ASSERT(!mTokenBuffer.empty()); return mTokenBuffer.front(); }