From 3e791db2015d47661cc640e41eb6a23914c86ad4 Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Sat, 7 Dec 2019 16:48:26 +0200 Subject: [PATCH] Prevent possible segfault on picking message IDs for deletion --- telegram/commands.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telegram/commands.go b/telegram/commands.go index 86477cc..5553580 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -251,6 +251,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) if c.me == nil { return "@me is not initialized", true } + var limit int32 if len(args) > 0 { limit64, err := strconv.ParseInt(args[0], 10, 32) @@ -275,7 +276,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool) var messageIds []int64 for _, message := range messages.Messages { - messageIds = append(messageIds, message.Id) + if message != nil { + messageIds = append(messageIds, message.Id) + } } _, err = c.client.DeleteMessages(&client.DeleteMessagesRequest{