fix out-of-bounds read when creating a multiplexed tracer

This commit is contained in:
Marten Seemann 2020-07-20 12:16:48 +07:00
parent 4e4c71c1b9
commit bd2b4e3e71
2 changed files with 62 additions and 50 deletions

View file

@ -17,7 +17,7 @@ func NewMultiplexedTracer(tracers ...Tracer) Tracer {
return nil
}
if len(tracers) == 1 {
return tracers[1]
return tracers[0]
}
return &tracerMultiplexer{tracers}
}

View file

@ -12,6 +12,17 @@ import (
var _ = Describe("Tracing", func() {
Context("Tracer", func() {
It("returns a nil tracer if no tracers are passed in", func() {
Expect(NewMultiplexedTracer()).To(BeNil())
})
It("returns the raw tracer if only one tracer is passed in", func() {
tr := NewMockTracer(mockCtrl)
tracer := NewMultiplexedTracer(tr)
Expect(tracer).To(BeAssignableToTypeOf(&MockTracer{}))
})
Context("tracing events", func() {
var (
tracer Tracer
tr1, tr2 *MockTracer
@ -71,6 +82,7 @@ var _ = Describe("Tracing", func() {
tracer.DroppedPacket(remote, PacketTypeRetry, 1024, PacketDropDuplicate)
})
})
})
Context("Connection Tracer", func() {
var (