dbms: FlatDictionary: fix off-by-one error on resize. [#METR-13298]

This commit is contained in:
Andrey Mironov 2015-03-23 16:25:34 +03:00
parent 33f41657df
commit f321a422b7

View File

@ -262,7 +262,7 @@ private:
{ {
auto & array = *std::get<std::unique_ptr<PODArray<T>>>(attribute.arrays); auto & array = *std::get<std::unique_ptr<PODArray<T>>>(attribute.arrays);
if (id >= array.size()) if (id >= array.size())
array.resize_fill(id, std::get<T>(attribute.null_values)); array.resize_fill(id + 1, std::get<T>(attribute.null_values));
array[id] = value; array[id] = value;
} }
@ -290,7 +290,7 @@ private:
{ {
auto & array = *std::get<std::unique_ptr<PODArray<StringRef>>>(attribute.arrays); auto & array = *std::get<std::unique_ptr<PODArray<StringRef>>>(attribute.arrays);
if (id >= array.size()) if (id >= array.size())
array.resize_fill(id, std::get<String>(attribute.null_values)); array.resize_fill(id + 1, std::get<String>(attribute.null_values));
const auto & string = value.get<String>(); const auto & string = value.get<String>();
const auto string_in_arena = attribute.string_arena->insert(string.data(), string.size()); const auto string_in_arena = attribute.string_arena->insert(string.data(), string.size());
array[id] = StringRef{string_in_arena, string.size()}; array[id] = StringRef{string_in_arena, string.size()};