From 240a274b0546f2d0fa5064785c87941831ed5b5d Mon Sep 17 00:00:00 2001 From: Congqi Xia Date: Wed, 8 Nov 2023 10:27:51 +0800 Subject: [PATCH] Fix unsafe direct field access for Int8/Int16 result data Signed-off-by: Congqi Xia --- client/data_test.go | 10 +++++----- entity/columns.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/data_test.go b/client/data_test.go index aff3bb91..4a588b77 100644 --- a/client/data_test.go +++ b/client/data_test.go @@ -870,14 +870,14 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) { // this injection returns float distance dl := 0 if idsLeft != nil { - dl = len(idsLeft.IdArray.GetIntId().Data) + dl = len(idsLeft.IdArray.GetIntId().GetData()) } if valuesLeft != nil { dl = len(valuesLeft.GetFloatVector().GetData()) / int(valuesLeft.Dim) } dr := 0 if idsRight != nil { - dr = len(idsRight.IdArray.GetIntId().Data) + dr = len(idsRight.IdArray.GetIntId().GetData()) } if valuesRight != nil { dr = len(valuesRight.GetFloatVector().GetData()) / int(valuesRight.Dim) @@ -935,14 +935,14 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) { // this injection returns float distance dl := 0 if idsLeft != nil { - dl = len(idsLeft.IdArray.GetIntId().Data) + dl = len(idsLeft.IdArray.GetIntId().GetData()) } if valuesLeft != nil { dl = len(valuesLeft.GetFloatVector().GetData()) / int(valuesLeft.Dim) } dr := 0 if idsRight != nil { - dr = len(idsRight.IdArray.GetIntId().Data) + dr = len(idsRight.IdArray.GetIntId().GetData()) } if valuesRight != nil { dr = len(valuesRight.GetFloatVector().GetData()) / int(valuesRight.Dim) @@ -1004,7 +1004,7 @@ func TestGrpcCalcDistanceWithIDs(t *testing.T) { assert.NotNil(t, idsRight.IdArray.GetStrId()) // this injection returns float distance - dl := len(idsLeft.IdArray.GetStrId().Data) + dl := len(idsLeft.IdArray.GetStrId().GetData()) resp.Array = &milvuspb.CalcDistanceResults_FloatDist{ FloatDist: &schemapb.FloatArray{ diff --git a/entity/columns.go b/entity/columns.go index b51a053d..59192e6b 100644 --- a/entity/columns.go +++ b/entity/columns.go @@ -319,7 +319,7 @@ func parseArrayData(fieldName string, array *schema.ArrayArray) (Column, error) case schema.DataType_Int8: var data [][]int8 for _, fd := range fieldDataList { - raw := fd.GetIntData().Data + raw := fd.GetIntData().GetData() row := make([]int8, 0, len(raw)) for _, item := range raw { row = append(row, int8(item)) @@ -331,7 +331,7 @@ func parseArrayData(fieldName string, array *schema.ArrayArray) (Column, error) case schema.DataType_Int16: var data [][]int16 for _, fd := range fieldDataList { - raw := fd.GetIntData().Data + raw := fd.GetIntData().GetData() row := make([]int16, 0, len(raw)) for _, item := range raw { row = append(row, int16(item))