aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2018-09-05 13:55:54 +0200
committerOndrej Fabry <ofabry@cisco.com>2018-09-05 13:55:54 +0200
commit6f6d2433ae72550cb4b603376ae8e6185256affe (patch)
tree2ef63d8b376a83ab4c310ab31c42d320d175a8b1
parent6b350c65fe0ec845cecf58bfb41ffc63dc9c04f7 (diff)
Copy data in msg callback
Change-Id: I642b0f586a57101633982bcee5bad187a0749090 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
-rw-r--r--core/request_handler.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/request_handler.go b/core/request_handler.go
index 14c095d..c042948 100644
--- a/core/request_handler.go
+++ b/core/request_handler.go
@@ -193,11 +193,12 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) {
// treat this as a last part of the reply
lastReplyReceived := isMulti && msgID == c.pingReplyID
- // send the data to the channel
+ // send the data to the channel, it needs to be copied,
+ // because it will be freed after this function returns
sendReply(ch, &vppReply{
msgID: msgID,
seqNum: seqNum,
- data: data,
+ data: append([]byte(nil), data...),
lastReceived: lastReplyReceived,
})