From e74213fefaf1fd9a3e573cf23db1568097824a6c Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 1 Oct 2020 18:54:35 +0200 Subject: [PATCH] :bug: Copy SRT data in another buffer before sending it in the forwarding package to avoid overwriting issues --- stream/srt/srt.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stream/srt/srt.go b/stream/srt/srt.go index 52ec3db..1195227 100644 --- a/stream/srt/srt.go +++ b/stream/srt/srt.go @@ -84,7 +84,10 @@ func Serve(cfg *Options, forwardingChannel chan Packet) { // log.Printf("Received %d bytes", n) // Send raw packet to other streams - forwardingChannel <- Packet{StreamName: "demo", PacketType: "sendData", Data: buff[:n]} + // Copy data in another buffer to ensure that the data would not be overwritten + data := make([]byte, n) + copy(data, buff[:n]) + forwardingChannel <- Packet{StreamName: "demo", PacketType: "sendData", Data: data} // TODO: Send to WebRTC // See https://github.com/ebml-go/webm/blob/master/reader.go