From eb4a328c89064fedc45f48d0b2cd6dd60a634df4 Mon Sep 17 00:00:00 2001 From: gullradriel Date: Thu, 12 Feb 2026 11:47:27 +0100 Subject: [PATCH] do not free/realloc furi_string as flipper_format_read_string is doing a reset of the string, check for problems and return error --- protocols/fiat_v0.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/protocols/fiat_v0.c b/protocols/fiat_v0.c index f259ae5..7e4ea86 100644 --- a/protocols/fiat_v0.c +++ b/protocols/fiat_v0.c @@ -226,18 +226,20 @@ SubGhzProtocolStatus do { FuriString* temp_str = furi_string_alloc(); + furi_check(temp_str); if(!flipper_format_read_string(flipper_format, "Protocol", temp_str)) { FURI_LOG_E(TAG, "Missing Protocol"); furi_string_free(temp_str); + temp_str = NULL; break; } if(!furi_string_equal(temp_str, instance->base.protocol->name)) { FURI_LOG_E(TAG, "Wrong protocol: %s", furi_string_get_cstr(temp_str)); furi_string_free(temp_str); + temp_str = NULL; break; } - furi_string_free(temp_str); uint32_t bit_count_temp; if(!flipper_format_read_uint32(flipper_format, "Bit", &bit_count_temp, 1)) { @@ -245,13 +247,18 @@ SubGhzProtocolStatus break; } - temp_str = furi_string_alloc(); if(!flipper_format_read_string(flipper_format, "Key", temp_str)) { FURI_LOG_E(TAG, "Missing Key"); furi_string_free(temp_str); + temp_str = NULL; break; } + // if no string to decode return error + if(!temp_str) { + return ret; + } + const char* key_str = furi_string_get_cstr(temp_str); uint64_t key = 0; size_t str_len = strlen(key_str);