aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2015-05-15 10:05:05 +1000
committerNeil <nyamatongwe@gmail.com>2015-05-15 10:05:05 +1000
commitc5116e3cd74bb0d760fbef1b9848a03475ab4f3c (patch)
tree5bc0ea9d11d2a8873f0fe968d7f92c57e72be743
parent0b299068c8f7e5d1331276919c4d73876e1a5a7a (diff)
downloadscintilla-mirror-c5116e3cd74bb0d760fbef1b9848a03475ab4f3c.tar.gz
Backed out changeset: 7caa35787c19
Change made reverse iteration dangerous.
-rw-r--r--doc/ScintillaHistory.html3
-rw-r--r--src/Document.cxx9
2 files changed, 5 insertions, 7 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 2113dacba..e2b770fb1 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -517,9 +517,6 @@
<a href="http://sourceforge.net/p/scintilla/bugs/1703/">Bug #1703</a>.
</li>
<li>
- Ensure SCI_POSITIONRELATIVE returns a position clamped into the document range sensibly.
- </li>
- <li>
Fix link error on Windows when SCI_NAMESPACE used.
</li>
<li>
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 {