Copilot commented on code in PR #793:
URL: 
https://github.com/apache/skywalking-banyandb/pull/793#discussion_r2382588226


##########
banyand/internal/sidx/element.go:
##########
@@ -166,7 +189,14 @@ func (e *elements) mustAppend(seriesID common.SeriesID, 
userKey int64, data []by
        for _, t := range tags {
                newTag := generateTag()
                newTag.name = t.Name
-               newTag.value = append([]byte(nil), t.Value...)
+               if t.ValueArr != nil {
+                       newTag.valueArr = make([][]byte, len(t.ValueArr))
+                       for i, v := range t.ValueArr {
+                               newTag.valueArr[i] = 
append(newTag.valueArr[i][:0], v...)

Review Comment:
   This line assumes `newTag.valueArr[i]` exists, but `newTag.valueArr[i]` is a 
nil slice from the make call on line 193. Use `append([]byte(nil), v...)` 
instead to properly copy the byte slice.
   ```suggestion
                                newTag.valueArr[i] = append([]byte(nil), v...)
   ```



##########
banyand/internal/sidx/element.go:
##########
@@ -166,7 +189,14 @@ func (e *elements) mustAppend(seriesID common.SeriesID, 
userKey int64, data []by
        for _, t := range tags {
                newTag := generateTag()
                newTag.name = t.Name
-               newTag.value = append([]byte(nil), t.Value...)
+               if t.ValueArr != nil {
+                       newTag.valueArr = make([][]byte, len(t.ValueArr))
+                       for i, v := range t.ValueArr {
+                               newTag.valueArr[i] = 
append(newTag.valueArr[i][:0], v...)
+                       }
+               } else {
+                       newTag.value = append(newTag.value[:0], t.Value...)

Review Comment:
   This line assumes `newTag.value` has capacity, but it's nil from the tag 
reset. Use `append([]byte(nil), t.Value...)` instead to properly allocate and 
copy the byte slice.
   ```suggestion
                        newTag.value = append([]byte(nil), t.Value...)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to