github-vet / github-vet/rangeloop-pointer-findings
briko-org/brikobot: msgserver.go; 64 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [briko-org/brikobot](https://www.github.com/briko-org/brikobot) at [msgserver.go](https://github.com/briko-org/brikobot/blob/c24820a08034d9c9b9b3e753b299975c6e29f6a9/msgserver.go#L148-L211)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> function call which takes a reference to update at line 208 may start a goroutine
[Click here to see the code in its original context.](https://github.com/briko-org/brikobot/blob/c24820a08034d9c9b9b3e753b299975c6e29f6a9/msgserver.go#L148-L211)
Click here to show the 64 line(s) of Go which triggered the analyzer.
```go
for update := range updates {
if update.CallbackQuery != nil {
callbackcmd := strings.Split(update.CallbackQuery.Data, "_")
if len(callbackcmd) == 2 { //is callback cmd
chat_id := int64(update.CallbackQuery.From.ID)
u_id := update.CallbackQuery.From.ID
cmd := callbackcmd[0]
glog.V(2).Infof("User Query %s from id %d", update.CallbackQuery.Data, update.CallbackQuery.From.ID)
if cmd == "SETLANG" || cmd == "SUBMIT" || cmd == "CANCEL" || cmd == "EDIT" || cmd == "PUBLISH" {
ProcessUpdateCmdMessage(bot, cmd, callbackcmd[1], choutput, db, update.CallbackQuery.Message.MessageID, u_id, chat_id)
bot.AnswerCallbackQuery(tgbotapi.NewCallback(update.CallbackQuery.ID, update.CallbackQuery.Data))
}
} else {
callbackdata := strings.Split(update.CallbackQuery.Data, ",")
if len(callbackdata) == 2 {
lang := callbackdata[0]
user_ranking, err := strconv.Atoi(callbackdata[1])
if err == nil { // error: ranking value must be a int
_, err = db.AddRanking(update.CallbackQuery.Message.Chat.ID, update.CallbackQuery.Message.MessageID, update.CallbackQuery.From.ID, lang, user_ranking)
if err != nil {
glog.Errorf("error: %v\n", err)
} else {
re_msg := tgbotapi.NewMessage(int64(update.CallbackQuery.From.ID), "")
re_msg.Text = fmt.Sprintf("Rating %s Message %d has been submitted.", update.CallbackQuery.Data, update.CallbackQuery.Message.MessageID)
bot.Send(re_msg)
}
} else {
glog.Errorf("rating value strconv error: %s %v\n", update.CallbackQuery.Data, err)
}
bot.AnswerCallbackQuery(tgbotapi.NewCallback(update.CallbackQuery.ID, update.CallbackQuery.Data))
}
}
}
if update.Message != nil {
chat_id := update.Message.Chat.ID
u_id := update.Message.From.ID
msgtext := "default text"
switch []byte(update.Message.Text)[0] {
case 63: //"?"
msgtext = HELP_TEXT
msg := tgbotapi.NewMessage(update.Message.Chat.ID, msgtext)
bot.Send(msg)
case 47: //start with "/"
msgtext := "unknown command. send ? or /help for help."
msg := tgbotapi.NewMessage(update.Message.Chat.ID, msgtext)
if update.Message.Text == "/help" || update.Message.Text == "/start" {
msgtext = HELP_TEXT
msg = tgbotapi.NewMessage(update.Message.Chat.ID, msgtext)
} else if update.Message.Text == "/join" {
msgtext = fmt.Sprintf("Your Telegram ID: %d", u_id)
msg = tgbotapi.NewMessage(update.Message.Chat.ID, msgtext)
} else if update.Message.Text == "/reset" || update.Message.Text == "/del" {
db.DelSession(chat_id, u_id)
msgtext = "Cleared, please input new content or url, or /help or /start for help."
msg = tgbotapi.NewMessage(update.Message.Chat.ID, msgtext)
}
bot.Send(msg)
default:
ProcessUpdateMessageChat(bot, &update, chspider, db, u_id, chat_id)
}
}
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(ProcessUpdateMessageChat, 6) -> (tryFetchUrl, 3)
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: c24820a08034d9c9b9b3e753b299975c6e29f6a9
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.