diff options
author | Neil <nyamatongwe@gmail.com> | 2015-05-15 10:05:05 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-05-15 10:05:05 +1000 |
commit | 19add104aee7fe970d99dc32ff06d025217f6eed (patch) | |
tree | 8fa18d3b628c802b6faaccf35de3ea89333433b3 /src/Document.cxx | |
parent | fec45da4064758bf6fb2ef06c386d1345348fae8 (diff) | |
download | scintilla-mirror-19add104aee7fe970d99dc32ff06d025217f6eed.tar.gz |
Backed out changeset: 7caa35787c19
Change made reverse iteration dangerous.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index c25dc84b9..7d34dace1 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -767,23 +767,24 @@ bool Document::NextCharacter(int &pos, int moveDir) const { } } +// Return -1 on out-of-bounds int SCI_METHOD Document::GetRelativePosition(int positionStart, int characterOffset) const { int pos = positionStart; if (dbcsCodePage) { const int increment = (characterOffset > 0) ? 1 : -1; while (characterOffset != 0) { const int posNext = NextPosition(pos, increment); - if (posNext == Length()) - return posNext; - else if (posNext == pos) + if (posNext == pos) return INVALID_POSITION; pos = posNext; characterOffset -= increment; } } else { pos = positionStart + characterOffset; + if ((pos < 0) || (pos > Length())) + return INVALID_POSITION; } - return ClampPositionIntoDocument(pos); + return pos; } int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const { |