diff options
author | nyamatongwe <devnull@localhost> | 2009-04-25 00:01:51 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2009-04-25 00:01:51 +0000 |
commit | 8224f04de0800f952a499303f3488d62b7facc9b (patch) | |
tree | f5192bd470067a68d1d8690039e7792d9f0af116 | |
parent | 15474bdf27b533accb95a4815b979e8d7ded3124 (diff) | |
download | scintilla-mirror-8224f04de0800f952a499303f3488d62b7facc9b.tar.gz |
Avoid out of bounds write when asked to add marker to line beyond end of
document.
-rw-r--r-- | src/Document.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
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<LineMarkers*>(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<LineMarkers*>(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) { |