mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix highway memory leak
This commit is contained in:
parent
38bb31b5a6
commit
3b461554b7
@ -28,6 +28,8 @@ type Session struct {
|
|||||||
seq int32
|
seq int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const highwayMaxResponseSize int32 = 1024 * 100 // 100k
|
||||||
|
|
||||||
func (s *Session) AddrLength() int {
|
func (s *Session) AddrLength() int {
|
||||||
return len(s.SsoAddr)
|
return len(s.SsoAddr)
|
||||||
}
|
}
|
||||||
@ -247,6 +249,9 @@ func readResponse(r *binary.NetworkReader) (*pb.RspDataHighwayHead, []byte, erro
|
|||||||
}
|
}
|
||||||
hl, _ := r.ReadInt32()
|
hl, _ := r.ReadInt32()
|
||||||
a2, _ := r.ReadInt32()
|
a2, _ := r.ReadInt32()
|
||||||
|
if hl > highwayMaxResponseSize || a2 > highwayMaxResponseSize {
|
||||||
|
return nil, nil, errors.Errorf("highway response invild. head size: %v body size: %v", hl, a2)
|
||||||
|
}
|
||||||
head, _ := r.ReadBytes(int(hl))
|
head, _ := r.ReadBytes(int(hl))
|
||||||
payload, _ := r.ReadBytes(int(a2))
|
payload, _ := r.ReadBytes(int(a2))
|
||||||
_, _ = r.ReadByte()
|
_, _ = r.ReadByte()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user