From fc175732e154b0a0d7ccad400d4953a00030beee Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Jan 2021 12:48:47 +0530 Subject: [PATCH] Fix CodeQL warning --- kitty/key_encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kitty/key_encoding.c b/kitty/key_encoding.c index 96e89608e..bd1d0d6e7 100644 --- a/kitty/key_encoding.c +++ b/kitty/key_encoding.c @@ -75,7 +75,7 @@ serialize(const EncodingData *data, char *output, const char csi_trailer) { int pos = 0; bool second_field_not_empty = data->has_mods || data->add_actions; bool third_field_not_empty = data->add_text; -#define P(fmt, ...) pos += snprintf(output + pos, KEY_BUFFER_SIZE - 2 - pos, fmt, __VA_ARGS__) +#define P(fmt, ...) pos += snprintf(output + pos, KEY_BUFFER_SIZE - 2 <= pos ? 0 : KEY_BUFFER_SIZE - 2 - pos, fmt, __VA_ARGS__) P("\x1b%s", "["); if (data->key != 1 || data->add_alternates || second_field_not_empty || third_field_not_empty) P("%u", data->key); if (data->add_alternates) {