From 189f3f7675e2979c32df56ab98085ffc3aa3643b Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 12 Feb 2021 12:28:36 +0100 Subject: Add comments. --- .../src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h | 1 + searchlib/src/vespa/searchlib/attribute/imported_search_context.h | 1 + searchlib/src/vespa/searchlib/attribute/reference_mappings.h | 1 + 3 files changed, 3 insertions(+) (limited to 'searchlib') diff --git a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h index ebcf3b821b7..cb803735b89 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_attribute_vector_read_guard.h @@ -41,6 +41,7 @@ protected: protected: uint32_t getTargetLid(uint32_t lid) const { + // Check range to avoid reading memory beyond end of mapping array return lid < _targetLids.size() ? _targetLids[lid] : 0u; } diff --git a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h index a37774476e0..caf9b2f3c11 100644 --- a/searchlib/src/vespa/searchlib/attribute/imported_search_context.h +++ b/searchlib/src/vespa/searchlib/attribute/imported_search_context.h @@ -40,6 +40,7 @@ class ImportedSearchContext : public ISearchContext { SearchContextParams _params; uint32_t getTargetLid(uint32_t lid) const { + // Check range to avoid reading memory beyond end of mapping array return lid < _targetLids.size() ? _targetLids[lid] : 0u; } diff --git a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h index 971ef1eaf93..84dea276740 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h @@ -87,6 +87,7 @@ public: return TargetLids(&_targetLids[0], committedDocIdLimit); } uint32_t getTargetLid(uint32_t doc) const { + // Check limit to avoid reading memory beyond end of valid mapping array return doc < _committedDocIdLimit ? _targetLids[doc] : 0u; } ReverseMappingRefs getReverseMappingRefs() const { -- cgit v1.2.3