From 9baf180a45455b32479ecca42e3532de3737a38a Mon Sep 17 00:00:00 2001 From: Francesco Date: Wed, 25 Mar 2026 00:35:28 +0100 Subject: [PATCH] refactor(types): add checks --- src/internal/common.h | 2 +- src/types.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal/common.h b/src/internal/common.h index 4f0531e..f44ac05 100644 --- a/src/internal/common.h +++ b/src/internal/common.h @@ -23,7 +23,7 @@ struct memory_buffer { typedef struct tgbot { char token[TOKEN_SIZE]; /**< Bot token. */ char api[API_SIZE]; /**< Bot API url. */ - int32_t offset; /**< Bot offset. */ + int64_t offset; /**< Bot offset. */ } tgbot_s; enum tgbot_opt_type { diff --git a/src/types.c b/src/types.c index e641a0a..34125f1 100644 --- a/src/types.c +++ b/src/types.c @@ -29,6 +29,10 @@ void tgbot_inlinekb_free(tgbot_inlinekeyboard_s *keyboard) { } tgbot_inlinekeyboardbutton_s *tgbot_inlinekb_button_at(tgbot_inlinekeyboard_s *keyboard, size_t row, size_t column) { + if (row >= keyboard->rows || column >= keyboard->columns) { + return NULL; + } + return &keyboard->buttons[row * keyboard->columns + column]; }