From 91c06a216826530f43fa7aa8924fc8c6293f86d2 Mon Sep 17 00:00:00 2001 From: derskythe Date: Mon, 26 Sep 2022 21:41:49 +0400 Subject: [PATCH] fix disable env allocation many times --- .../plugins/subbrute/subbrute_device.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/applications/plugins/subbrute/subbrute_device.c b/applications/plugins/subbrute/subbrute_device.c index 6262eeff4..037a0f11b 100644 --- a/applications/plugins/subbrute/subbrute_device.c +++ b/applications/plugins/subbrute/subbrute_device.c @@ -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