From 2ccadd5db01321d0c631209b424859cf74b0468f Mon Sep 17 00:00:00 2001 From: nekijbt <81611207+nekijbt@users.noreply.github.com> Date: Tue, 30 Mar 2021 11:58:59 +0500 Subject: [PATCH] Memoru leak in telebot_get_updates() Declaring another one internal variable "struct json_object *array" in curly braces makes next call "json_object_put(array)" meaningless, not freing LOST pointer to "array" and cause memory leak. --- src/telebot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/telebot.c b/src/telebot.c index 6710643..47aba37 100644 --- a/src/telebot.c +++ b/src/telebot.c @@ -153,7 +153,7 @@ telebot_error_e telebot_get_updates(telebot_handler_t handle, int offset, struct json_object *array = NULL; if (allowed_updates_count > 0) { - struct json_object *array = json_object_new_array(); + array = json_object_new_array(); for (int i = 0; i < allowed_updates_count; i++) { const char *item = telebot_update_type_str[allowed_updates[i]]; json_object_array_add(array, json_object_new_string(item));