From 98e6b6ff51e05ae08e31c81954ff10dfb7191be5 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 15 May 2021 17:18:59 +1000 Subject: Protect against out-of-bounds layout cache level and remove unnecessary code. Make documentation more accurate. --- src/Editor.cxx | 4 +++- src/PositionCache.cxx | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index a2a2377ef..234e40700 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6763,7 +6763,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrap.indentMode; case SCI_SETLAYOUTCACHE: - view.llc.SetLevel(static_cast(wParam)); + if (wParam <= SC_CACHE_DOCUMENT) { + view.llc.SetLevel(static_cast(wParam)); + } break; case SCI_GETLAYOUTCACHE: diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index c1e0a77bd..1839f2072 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -463,8 +463,7 @@ void LineLayoutCache::Invalidate(LineLayout::ValidLevel validity_) noexcept { } void LineLayoutCache::SetLevel(Cache level_) noexcept { - allInvalidated = false; - if ((static_cast(level_) != -1) && (level != level_)) { + if (level != level_) { level = level_; allInvalidated = false; cache.clear(); -- cgit v1.2.3