From e29fbc46b5d542ab3975c512c478fdc2023f348f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 25 Apr 2009 00:01:51 +0000 Subject: Avoid out of bounds write when asked to add marker to line beyond end of document. --- src/Document.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Document.cxx b/src/Document.cxx index f7e9dfdcc..ac37215b2 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -138,11 +138,15 @@ int Document::GetMark(int line) { } int Document::AddMark(int line, int markerNum) { - int prev = static_cast(perLineData[ldMarkers])-> - AddMark(line, markerNum, LinesTotal()); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); - NotifyModified(mh); - return prev; + if (line <= LinesTotal()) { + int prev = static_cast(perLineData[ldMarkers])-> + AddMark(line, markerNum, LinesTotal()); + DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); + NotifyModified(mh); + return prev; + } else { + return 0; + } } void Document::AddMarkSet(int line, int valueSet) { -- cgit v1.2.3