flipper_format_free after all and only if we failed with all plans

This commit is contained in:
DerSkythe
2022-10-11 21:09:41 +04:00
parent b6dfeac7ca
commit 34406f0607

View File

@@ -445,6 +445,10 @@ bool subghz_history_add_to_history(
// Plan B!
subghz_history_tmp_write_file_full(instance, item, dir_path);
}
if (item->is_file) {
flipper_format_free(item->flipper_string);
item->flipper_string = NULL;
}
furi_string_free(filename);
furi_string_free(dir_path);
@@ -857,9 +861,8 @@ bool subghz_history_tmp_write_file_split(
flipper_format_file_close(flipper_format_file);
flipper_format_free(flipper_format_file);
furi_string_free(temp_str);
flipper_format_free(item->flipper_string);
item->flipper_string = NULL;
item->is_file = true;
item->is_file = result;
return result;
}
@@ -876,8 +879,6 @@ void subghz_history_tmp_write_file_full(
stream_rewind(dst);
if(stream_save_to_file(
dst, instance->storage, furi_string_get_cstr(dir_path), FSOM_CREATE_ALWAYS) > 0) {
flipper_format_free(item->flipper_string);
item->flipper_string = NULL;
#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Save done!");
#endif