This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git
The following commit(s) were added to refs/heads/main by this push:
new ff46ccf Fix Combine buffer panic when analyze protocol (#184)
ff46ccf is described below
commit ff46ccf3a5c3bf36c0b927bc173fad0f8d6d7319
Author: mrproliu <[email protected]>
AuthorDate: Tue Mar 11 16:12:34 2025 +0800
Fix Combine buffer panic when analyze protocol (#184)
---
pkg/tools/buffer/buffer.go | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/pkg/tools/buffer/buffer.go b/pkg/tools/buffer/buffer.go
index 33f6d1c..5a2ed13 100644
--- a/pkg/tools/buffer/buffer.go
+++ b/pkg/tools/buffer/buffer.go
@@ -437,9 +437,18 @@ func CombineSlices(validated bool, originalBuffer *Buffer,
buffers ...*Buffer) *
}
}
- var endPosition = buffers[len(buffers)-1].endPosition
- if endPosition == nil {
- endPosition = buffers[len(buffers)-1].Position()
+ var endPosition *Position
+ for i := len(buffers) - 1; i >= 0; i-- {
+ if buffers[i] == nil {
+ continue
+ }
+ if buffers[i].endPosition != nil {
+ endPosition = buffers[i].endPosition
+ break
+ } else if buffers[i].Position() != nil {
+ endPosition = buffers[i].Position()
+ break
+ }
}
return &Buffer{
dataEvents: dataEvents,