Bot crashes at telebot_destroy(handle);
Closed this issue · 2 comments
denzen84 commented
Hi,
I wrote simple bot that sends a message from command line. It sends message normally and crashes after call telebot_destroy(handle);
.
telebot_handler_t handle;
if (telebot_create(&handle, token) != TELEBOT_ERROR_NONE) {
printf("Telebot create failed\n");
return -1;
}
telebot_error_e ret;
if (!strcmp(argv[1],"--sendtext")) {
ret = telebot_send_message(handle, group_id, argv[2], "", false, false, 0, "");
if (ret != TELEBOT_ERROR_NONE) {
printf("Failed to send text message: %d \n", ret);
}
} else {
printf("Unrecognized command\n");
}
telebot_destroy(handle);
}
denzen84 commented
After some investigations I found anomaly behaivor in code:
telebot_error_e telebot_send_message(telebot_handler_t handle, int chat_id,
char *text, char *parse_mode, bool disable_web_page_preview,
bool disable_notification, int reply_to_message_id,
const char *reply_markup)
{
(...)
tb_sfree_zcnt(_handle->core_h->resp_data, &(_handle->core_h->resp_size));
(...)
After call tb_sfree_zcnt
pointer _handle->core_h->resp_data
was still not-NULL. I didn't find why this function worked abnormal in such case. But when I made code that releases pointer _handle->core_h->resp_data
directly in the body of function telebot_send_message
, all works fine.
Platform: OrangePi One, Debian Stretch, compiler: gcc 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
I have no idea why the original code doesn't work.