From 3c85e3a83b0d2f7da09b7b2573cb799842285ca7 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 7 Dec 2015 11:08:40 +1100 Subject: Prefer StyleIndexAt over StyleAt to avoid problems with out-of-bounds access for styles > 0x7f. --- src/Editor.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Editor.cxx') diff --git a/src/Editor.cxx b/src/Editor.cxx index 170f6a931..9c2703ab0 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -764,7 +764,7 @@ bool Editor::RangeContainsProtected(int start, int end) const { end = t; } for (int pos = start; pos < end; pos++) { - if (vs.styles[pdoc->StyleAt(pos)].IsProtected()) + if (vs.styles[pdoc->StyleIndexAt(pos)].IsProtected()) return true; } } @@ -4560,7 +4560,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } bool Editor::PositionIsHotspot(int position) const { - return vs.styles[static_cast(pdoc->StyleAt(position))].hotspot; + return vs.styles[pdoc->StyleIndexAt(position)].hotspot; } bool Editor::PointIsHotspot(Point pt) { @@ -4994,9 +4994,9 @@ void Editor::StyleToPositionInView(Position pos) { int endWindow = PositionAfterArea(GetClientDrawingRectangle()); if (pos > endWindow) pos = endWindow; - int styleAtEnd = pdoc->StyleAt(pos-1); + const int styleAtEnd = pdoc->StyleIndexAt(pos-1); pdoc->EnsureStyledTo(pos); - if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { + if ((endWindow > pos) && (styleAtEnd != pdoc->StyleIndexAt(pos-1))) { // Style at end of line changed so is multi-line change like starting a comment // so require rest of window to be styled. DiscardOverdraw(); // Prepared bitmaps may be invalid -- cgit v1.2.3