diff options
-rw-r--r-- | lib/Buffer.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc index 68ecb9e..473da62 100644 --- a/lib/Buffer.cc +++ b/lib/Buffer.cc @@ -181,9 +181,11 @@ bool Buffer::CanSeek() const { } off_t Buffer::seek(off_t off, int wheel) throw (GeneralException) { + size_t old_ptr; if (!seekable) { throw GeneralException("This buffer is a fifo, thus is not seekable"); } + old_ptr = ptr; switch (wheel) { case SEEK_SET: ptr = off; @@ -195,6 +197,10 @@ off_t Buffer::seek(off_t off, int wheel) throw (GeneralException) { ptr = realsiz + off; break; } + if (ptr < 0) { + ptr = old_ptr; + throw GeneralException("Can't seek a Buffer before its start.") + } operator[](ptr); return ptr; } |