diff options
author | Henning Baldersheim <balder@oath.com> | 2018-12-05 15:49:24 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-12-05 15:49:24 +0100 |
commit | a82407a2e9e87ea500a7138e27558883ad6795c5 (patch) | |
tree | dc51794540be127eb4f82b2939b74f9fc5ab8d89 /searchlib | |
parent | 1133e400cedd54104fd30f5bf267498db13fd9e7 (diff) |
Add assert to check sanity of input.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/datastore/entryref.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/searchlib/src/vespa/searchlib/datastore/entryref.h b/searchlib/src/vespa/searchlib/datastore/entryref.h index 433c260de32..9321ad8b8d1 100644 --- a/searchlib/src/vespa/searchlib/datastore/entryref.h +++ b/searchlib/src/vespa/searchlib/datastore/entryref.h @@ -3,6 +3,7 @@ #pragma once #include <cstdint> +#include <cassert> namespace search::datastore { @@ -28,7 +29,11 @@ class EntryRefT : public EntryRef { public: EntryRefT() : EntryRef() {} EntryRefT(uint64_t offset_, uint32_t bufferId_) : - EntryRef((offset_ << BufferBits) + bufferId_) {} + EntryRef((offset_ << BufferBits) + bufferId_) + { + assert(offset_ < offsetSize()); + assert(bufferId_ < numBuffers()); + } EntryRefT(const EntryRef & ref_) : EntryRef(ref_.ref()) {} uint32_t hash() const { return offset() + (bufferId() << OffsetBits); } uint64_t offset() const { return _ref >> BufferBits; } |