From 33d9ea9f7d2403884838faf64b04cf66318fc1b6 Mon Sep 17 00:00:00 2001 From: FelixKratz Date: Wed, 8 Sep 2021 21:30:01 +0200 Subject: [PATCH] malloc rbr string --- src/message.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/message.c b/src/message.c index dcb39a2..c895ea5 100644 --- a/src/message.c +++ b/src/message.c @@ -512,10 +512,11 @@ static void handle_domain_batch(FILE* rsp, struct token domain, char* message) { char* key = NULL; char* value = NULL; get_key_value_pair(token.text, &key, &value); - char rbr_msg[strlen(key) + (value ? strlen(value) : 1)]; + char* rbr_msg = malloc((strlen(key) + strlen(value) + 3) * sizeof(char)); pack_key_value_pair(rbr_msg, key, value); bar_item_parse_set_message(bar_item, rbr_msg); + free(rbr_msg); token = get_token(&message); } } else if (token_equals(command, COMMAND_BATCH_DEFAULT)) { @@ -524,10 +525,11 @@ static void handle_domain_batch(FILE* rsp, struct token domain, char* message) { char* key = NULL; char* value = NULL; get_key_value_pair(token.text, &key, &value); - char rbr_msg[strlen(key) + (value ? strlen(value) : 1)]; + char* rbr_msg = malloc((strlen(key) + strlen(value) + 3) * sizeof(char)); pack_key_value_pair(rbr_msg, key, value); handle_domain_default(rsp, domain, rbr_msg); + free(rbr_msg); token = get_token(&message); } } else if (token_equals(command, COMMAND_BATCH_CONFIG)) { @@ -536,10 +538,11 @@ static void handle_domain_batch(FILE* rsp, struct token domain, char* message) { char* key = NULL; char* value = NULL; get_key_value_pair(token.text, &key, &value); - char rbr_msg[strlen(key) + (value ? strlen(value) : 1)]; + char* rbr_msg = malloc((strlen(key) + strlen(value) + 3) * sizeof(char)); pack_key_value_pair(rbr_msg, key, value); if (key && value) handle_domain_config(rsp, domain, rbr_msg); + free(rbr_msg); token = get_token(&message); } }