Skip to content

Commit

Permalink
chore: prevent memory leak on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Jun 9, 2024
1 parent 4b6edc8 commit 894455d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/scenes/mtp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ void MTP_on_exit(void* context) {
return;
}

if(app->allocated_scenes != NULL) {
AppMTP* mtp = app->allocated_scenes[THIS_SCENE];
if(mtp != NULL) {
// free all handles
FileHandle* handle = mtp->handles;
mtp->handles = NULL;

while(handle != NULL) {
FileHandle* next = handle->next;

if(handle->path != NULL) free(handle->path);
free(handle);

handle = next;
}
}
}

furi_record_close(RECORD_STORAGE);

// revert to old usb mode
furi_hal_usb_set_config(tmp->old_usb, NULL);

Expand Down

0 comments on commit 894455d

Please sign in to comment.