aboutsummaryrefslogtreecommitdiff
path: root/telegram/commands.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-12-07 17:48:26 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-12-07 17:48:26 +0300
commit3e791db2015d47661cc640e41eb6a23914c86ad4 (patch)
tree4862ccf80773b2ff840f5d1cde3a66ce77c498d2 /telegram/commands.go
parent0013baa247b54286fb86119b91a5180f4334f463 (diff)
Prevent possible segfault on picking message IDs for deletion
Diffstat (limited to 'telegram/commands.go')
-rw-r--r--telegram/commands.go5
1 files changed, 4 insertions, 1 deletions
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{