diff options
author | nyamatongwe <devnull@localhost> | 2012-03-27 10:17:29 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2012-03-27 10:17:29 +1100 |
commit | 53c2cb986893475ac5c6559f935f279b34cfe0e2 (patch) | |
tree | 0348094925d4ecd501662d2757405f275bbb97a0 /src/Document.cxx | |
parent | 1c15808d6a1a3f56617c11cdab4a1ee0882cad17 (diff) | |
download | scintilla-mirror-53c2cb986893475ac5c6559f935f279b34cfe0e2.tar.gz |
Protect against modifying annotations with a negative line number or a line
number after the document end.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r-- | src/Document.cxx | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 0c73024d5..5ad558b8b 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1773,12 +1773,14 @@ StyledText Document::AnnotationStyledText(int line) { } void Document::AnnotationSetText(int line, const char *text) { - const int linesBefore = AnnotationLines(line); - static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetText(line, text); - const int linesAfter = AnnotationLines(line); - DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line); - mh.annotationLinesAdded = linesAfter - linesBefore; - NotifyModified(mh); + if (line >= 0 && line < LinesTotal()) { + const int linesBefore = AnnotationLines(line); + static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetText(line, text); + const int linesAfter = AnnotationLines(line); + DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line); + mh.annotationLinesAdded = linesAfter - linesBefore; + NotifyModified(mh); + } } void Document::AnnotationSetStyle(int line, int style) { @@ -1788,7 +1790,9 @@ void Document::AnnotationSetStyle(int line, int style) { } void Document::AnnotationSetStyles(int line, const unsigned char *styles) { - static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyles(line, styles); + if (line >= 0 && line < LinesTotal()) { + static_cast<LineAnnotation *>(perLineData[ldAnnotation])->SetStyles(line, styles); + } } int Document::AnnotationLength(int line) const { |