1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-12-01 03:03:48 +00:00

state: Fix Messages() OOB panic

This commit is contained in:
diamondburned 2022-04-04 21:36:26 -07:00
parent ec4cd6d661
commit 34db90a16d
No known key found for this signature in database
GPG key ID: D78C4471CE776659

View file

@ -603,7 +603,7 @@ func (s *State) Message(
// first. The returned slice will be sorted from latest to oldest.
func (s *State) Messages(channelID discord.ChannelID, limit uint) ([]discord.Message, error) {
storeMessages, err := s.Cabinet.Messages(channelID)
if err == nil && s.tracksMessage(&storeMessages[0]) {
if len(storeMessages) > 0 && s.tracksMessage(&storeMessages[0]) {
// Is the channel tiny?
s.fewMutex.Lock()
if _, ok := s.fewMessages[channelID]; ok {