diff --git a/src/include/relation.cpp b/src/include/relation.cpp index 8f1f81782..08c4c38f0 100755 --- a/src/include/relation.cpp +++ b/src/include/relation.cpp @@ -1184,6 +1184,8 @@ TRecnotype TCursor::buildcursor(TRecnotype rp) } _pagefirstpos = ap > _cmaxelpage ? -(_cmaxelpage + 1) : 0L ; + if (_pos < 0L) + _pos = 0L; return ap; } @@ -1748,9 +1750,11 @@ TRecnotype TCursor::readrec() } f.setstatus(NOERR); - if (_pos < _pagefirstpos || _pos >= _pagefirstpos + _cmaxelpage) + if (_pos < 0) + _pos = 0; + if (_pos < _pagefirstpos || _pos >= _pagefirstpos + _cmaxelpage) read_page(_pos / _cmaxelpage); - nrec = _page[_pos - _pagefirstpos]; + nrec = _page[_pos - _pagefirstpos]; CHECKD(nrec >= 0, "Bad record position ", nrec); curr().setdirty();