fix disable env allocation many times

This commit is contained in:
derskythe 2022-09-26 21:41:49 +04:00
parent 545c4349d6
commit 91c06a2168

View File

@ -60,7 +60,7 @@ SubBruteDevice* subbrute_device_alloc() {
instance->decoder_result = NULL;
instance->receiver = NULL;
instance->environment = NULL;
instance->environment = subghz_environment_alloc();
subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit307);
@ -84,13 +84,8 @@ void subbrute_device_free(SubBruteDevice* instance) {
instance->receiver = NULL;
}
if(instance->environment != NULL) {
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "subghz_environment_free");
#endif
subghz_environment_free(instance->environment);
instance->environment = NULL;
}
subghz_environment_free(instance->environment);
instance->environment = NULL;
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "before free");
@ -236,7 +231,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
FURI_LOG_D(TAG, "candidate: %s, step: %d", string_get_cstr(candidate), step);
#endif
if (small) {
if(small) {
if(instance->has_tail) {
snprintf(
instance->payload,
@ -358,7 +353,6 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
}
// For non-file types we didn't set SubGhzProtocolDecoderBase
instance->environment = subghz_environment_alloc();
instance->receiver = subghz_receiver_alloc_init(instance->environment);
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
furi_hal_subghz_reset();
@ -380,10 +374,8 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
protocol_check_result = SubBruteFileResultOk;
}
subghz_environment_free(instance->environment);
subghz_receiver_free(instance->receiver);
instance->receiver = NULL;
instance->environment = NULL;
if(protocol_check_result != SubBruteFileResultOk) {
return SubBruteFileResultProtocolNotFound;
@ -447,7 +439,6 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
string_init(temp_str);
uint32_t temp_data32;
instance->environment = subghz_environment_alloc();
instance->receiver = subghz_receiver_alloc_init(instance->environment);
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
furi_hal_subghz_reset();
@ -582,12 +573,10 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
subghz_environment_free(instance->environment);
subghz_receiver_free(instance->receiver);
instance->decoder_result = NULL;
instance->receiver = NULL;
instance->environment = NULL;
if(result == SubBruteFileResultOk) {
#ifdef FURI_DEBUG