mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
fix(guild): add nil guards in cancel and answer scout handlers
GetByID returns (nil, nil) for deleted guilds, and AnswerScout can return nil result on ErrApplicationMissing, both leading to nil dereferences.
This commit is contained in:
@@ -48,7 +48,7 @@ func handleMsgMhfCancelGuildScout(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
guild, err := s.server.guildRepo.GetByID(guildCharData.GuildID)
|
||||
|
||||
if err != nil {
|
||||
if err != nil || guild == nil {
|
||||
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
@@ -87,14 +87,19 @@ func handleMsgMhfAnswerGuildScout(s *Session, p mhfpacket.MHFPacket) {
|
||||
bf := byteframe.NewByteFrame()
|
||||
if result != nil && result.Success {
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint32(result.GuildID)
|
||||
} else {
|
||||
if errors.Is(err, ErrApplicationMissing) {
|
||||
s.logger.Warn("Guild invite missing, deleted?",
|
||||
zap.Uint32("charID", s.charID))
|
||||
}
|
||||
bf.WriteUint32(7)
|
||||
}
|
||||
if result != nil {
|
||||
bf.WriteUint32(result.GuildID)
|
||||
} else {
|
||||
bf.WriteUint32(0)
|
||||
}
|
||||
}
|
||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user