do not free/realloc furi_string as flipper_format_read_string is doing a reset of the string, check for problems and return error

This commit is contained in:
gullradriel
2026-02-12 11:47:27 +01:00
parent c4c7b6baee
commit eb4a328c89
+9 -2
View File
@@ -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);