Skip to content

Commit

Permalink
add missing furi_string_free
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Jan 11, 2024
1 parent 9721102 commit c61f86f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps_source_code/brainfuck/brainfuck.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void brainfuck_free(BFApp* brainfuck) {
// Scene Manager
scene_manager_free(brainfuck->scene_manager);

// Free file path
furi_string_free(brainfuck->BF_file_path);

// GUI
furi_record_close(RECORD_GUI);
brainfuck->gui = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void brainfuck_scene_file_select_on_enter(void* context) {
} else {
scene_manager_search_and_switch_to_previous_scene(app->scene_manager, brainfuckSceneStart);
}
furi_string_free(path);
}

bool brainfuck_scene_file_select_on_event(void* context, SceneManagerEvent event) {
Expand Down
2 changes: 2 additions & 0 deletions apps_source_code/color_guess/helpers/color_guess_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ void color_guess_read_settings(void* context) {
FURI_LOG_E(TAG, "Missing Header Data");
color_guess_close_config_file(fff_file);
color_guess_close_storage();
furi_string_free(temp_str);
return;
}
furi_string_free(temp_str);

if(file_version < COLOR_GUESS_SETTINGS_FILE_VERSION) {
FURI_LOG_I(TAG, "old config version, will be removed.");
Expand Down
2 changes: 2 additions & 0 deletions base_pack/camera_suite/helpers/camera_suite_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ void camera_suite_read_settings(void* context) {
FURI_LOG_E(TAG, "Missing Header Data");
camera_suite_close_config_file(fff_file);
camera_suite_close_storage();
furi_string_free(temp_str);
return;
}
furi_string_free(temp_str);

if(file_version < BOILERPLATE_SETTINGS_FILE_VERSION) {
FURI_LOG_I(TAG, "old config version, will be removed.");
Expand Down
2 changes: 2 additions & 0 deletions base_pack/hex_viewer/helpers/hex_viewer_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ void hex_viewer_read_settings(void* context) {
FURI_LOG_E(TAG, "Missing Header Data");
hex_viewer_close_config_file(fff_file);
hex_viewer_close_storage();
furi_string_free(temp_str);
return;
}
furi_string_free(temp_str);

if(file_version < HEX_VIEWER_SETTINGS_FILE_VERSION) {
FURI_LOG_I(TAG, "old config version, will be removed.");
Expand Down
3 changes: 3 additions & 0 deletions base_pack/lightmeter/lightmeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ void lightmeter_app_free(LightMeterApp* app) {

bh1750_set_power_state(0);

// Free cfg path string
furi_string_free(app->cfg_path);

free(app->config);
free(app);
}
Expand Down
8 changes: 8 additions & 0 deletions base_pack/unitemp/Sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ bool unitemp_sensors_load(void) {
//Открытие потока к файлу с датчиками
if(!file_stream_open(
app->file_stream, furi_string_get_cstr(filepath), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) {
// Free file path string if we got an error
furi_string_free(filepath);
if(file_stream_get_error(app->file_stream) == FSE_NOT_EXIST) {
FURI_LOG_W(APP_NAME, "Missing sensors file");
//Закрытие потока и освобождение памяти
Expand All @@ -309,6 +311,8 @@ bool unitemp_sensors_load(void) {
return false;
}
}
// Free file path string if we successfully opened the file
furi_string_free(filepath);

//Вычисление размера файла
uint16_t file_size = stream_size(app->file_stream);
Expand Down Expand Up @@ -402,6 +406,8 @@ bool unitemp_sensors_save(void) {
//Открытие потока
if(!file_stream_open(
app->file_stream, furi_string_get_cstr(filepath), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) {
// Free file path string if we got an error
furi_string_free(filepath);
FURI_LOG_E(
APP_NAME,
"An error occurred while saving the sensors file: %d",
Expand All @@ -411,6 +417,8 @@ bool unitemp_sensors_save(void) {
stream_free(app->file_stream);
return false;
}
// Free file path string if we successfully opened the file
furi_string_free(filepath);

//Сохранение датчиков
for(uint8_t i = 0; i < unitemp_sensors_getActiveCount(); i++) {
Expand Down
10 changes: 10 additions & 0 deletions base_pack/unitemp/unitemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ bool unitemp_saveSettings(void) {
//Открытие потока
if(!file_stream_open(
app->file_stream, furi_string_get_cstr(filepath), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) {
// Free file path string if we got an error
furi_string_free(filepath);
FURI_LOG_E(
APP_NAME,
"An error occurred while saving the settings file: %d",
Expand All @@ -99,6 +101,8 @@ bool unitemp_saveSettings(void) {
//Закрытие потока и освобождение памяти
file_stream_close(app->file_stream);
stream_free(app->file_stream);
// Free file path string if we successfully opened the file
furi_string_free(filepath);

FURI_LOG_I(APP_NAME, "Settings have been successfully saved");
return true;
Expand All @@ -124,6 +128,8 @@ bool unitemp_loadSettings(void) {
//Закрытие потока и освобождение памяти
file_stream_close(app->file_stream);
stream_free(app->file_stream);
// Free file path string if we got an error
furi_string_free(filepath);
//Сохранение стандартного конфига
unitemp_saveSettings();
return false;
Expand All @@ -135,9 +141,13 @@ bool unitemp_loadSettings(void) {
//Закрытие потока и освобождение памяти
file_stream_close(app->file_stream);
stream_free(app->file_stream);
// Free file path string if we got an error
furi_string_free(filepath);
return false;
}
}
// Free file path string if we successfully opened the file
furi_string_free(filepath);

//Вычисление размера файла
uint8_t file_size = stream_size(app->file_stream);
Expand Down
1 change: 1 addition & 0 deletions non_catalog_apps/coffee_eeprom/coffee.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void dump(uint8_t* out){
}
FURI_LOG_E("COFFEE_eeprom", furi_string_get_cstr(dump_str));
FURI_LOG_E("COFFEE_eeprom", "End dump");
furi_string_free(dump_str);
}else{
FURI_LOG_D("COFFEE", "DUMP: EEPROM not ready %x (8-bit)", EEPROM_I2C_ADDR);
}
Expand Down
2 changes: 2 additions & 0 deletions non_catalog_apps/coffee_eeprom/coffee_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void load_file_dump(){
if(!storage_file_open(file, furi_string_get_cstr(file_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
FURI_LOG_E(TAG, "Failed to open file");
}
furi_string_free(file_path);
uint8_t buffer[256] = {0};

uint16_t read = 0;
Expand Down Expand Up @@ -123,6 +124,7 @@ void load_file_dump(){
}
FURI_LOG_E(TAG, "%s", furi_string_get_cstr(dump));
FURI_LOG_E(TAG, "END READ DUMP");
furi_string_free(dump);
write_dump(buffer, (size_t) read);
break;
}
Expand Down
2 changes: 2 additions & 0 deletions non_catalog_apps/sd_spi/sd_spi_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void app_scene_on_enter_info(void* context) {
furi_string_cat_printf(temp_str, "Github: %s\n\n", GITHUB);

widget_add_text_scroll_element(app->widget_about, 0, 16, 128, 50, furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
view_dispatcher_switch_to_view(app->view_dispatcher, AppView_Info);
}
bool app_scene_on_event_info(void* context, SceneManagerEvent event) {
Expand Down Expand Up @@ -381,6 +382,7 @@ void app_scene_on_enter_status(void* context) {

text_box_set_text(app->tb_status, furi_string_get_cstr(fs_status));
text_box_set_focus(app->tb_status, TextBoxFocusEnd);
furi_string_free(fs_status);
view_dispatcher_switch_to_view(app->view_dispatcher, AppView_Status);
}
bool app_scene_on_event_status(void* context, SceneManagerEvent event) {
Expand Down

0 comments on commit c61f86f

Please sign in to comment.