Skip to content

Commit 4e040cf

Browse files
committed
vecstore: when reusing memory, set length to the desired length
Previously, when reusing memory for the output field, PKDecoder.Init() would truncate the output field instead of setting it to the desired length. This could lead to a runtime out of bounds memory reference. Epic: none Release note (bug fix): An issue that could cause vector index uses to throw an out of bounds access exception has been fixed.
1 parent c013c36 commit 4e040cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/sql/vecindex/vecstore/store_txn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (d *PKDecoder) Init(fetchSpec *fetchpb.IndexFetchSpec) {
384384
if cap(d.output) < len(fetchSpec.FetchedColumns) {
385385
d.output = make(rowenc.EncDatumRow, len(fetchSpec.FetchedColumns))
386386
} else {
387-
d.output = d.output[:0]
387+
d.output = d.output[:len(fetchSpec.FetchedColumns)]
388388
}
389389
for i, col := range fetchSpec.FetchedColumns {
390390
d.colOrdMap.Set(col.ColumnID, i)

0 commit comments

Comments
 (0)