fix off-by-one assumption regarding vector indexing dating to 2011

This commit is contained in:
Vern Paxson 2021-02-24 16:11:27 -08:00
parent 3179df9ab2
commit e64805430b
4 changed files with 29 additions and 31 deletions

View file

@ -352,7 +352,7 @@ VectorVal* String:: VecToPolicy(Vec* vec)
String* string = (*vec)[i];
auto val = make_intrusive<StringVal>(string->Len(),
(const char*) string->Bytes());
result->Assign(i+1, std::move(val));
result->Assign(i, std::move(val));
}
return result.release();
@ -362,8 +362,7 @@ String::Vec* String::VecFromPolicy(VectorVal* vec)
{
Vec* result = new Vec();
// VectorVals start at index 1!
for ( unsigned int i = 1; i <= vec->Size(); ++i )
for ( unsigned int i = 0; i < vec->Size(); ++i )
{
const auto& v = vec->At(i); // get the RecordVal
if ( ! v )