diff options
author | nyamatongwe <unknown> | 2012-03-27 10:17:29 +1100 |
---|---|---|
committer | nyamatongwe <unknown> | 2012-03-27 10:17:29 +1100 |
commit | d716ac0173cc608a61503ada0f907637285a5d8d (patch) | |
tree | 5f7e95dcbe5d59ce74614cece3ab747cbc0e243e /src/Document.cxx | |
parent | 277230dd1ecc8a0f4a359160ad13a68b84dc9e9e (diff) | |
download | scintilla-mirror-d716ac0173cc608a61503ada0f907637285a5d8d.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 { |