@@ -71,6 +71,23 @@ typedef struct {
7171
7272static t_ui_context * ui_ctx = NULL ;
7373
74+ // to be used as a \ref f_list_node_del
75+ static void delete_filter_crc (s_filter_crc * fcrc ) {
76+ app_mem_free (fcrc );
77+ }
78+
79+ // to be used as a \ref f_list_node_del
80+ static void delete_ui_pair (s_ui_712_pair * pair ) {
81+ if (pair -> key != NULL ) app_mem_free (pair -> key );
82+ if (pair -> value != NULL ) app_mem_free (pair -> value );
83+ app_mem_free (pair );
84+ }
85+
86+ // to be used as a \ref f_list_node_del
87+ static void delete_amount_join (s_amount_join * join ) {
88+ app_mem_free (join );
89+ }
90+
7491/**
7592 * Checks on the UI context to determine if the next EIP 712 field should be shown
7693 *
@@ -485,7 +502,9 @@ static bool ui_712_format_amount_join(void) {
485502 }
486503 ui_ctx -> field_flags |= UI_712_FIELD_SHOWN ;
487504 ui_712_set_title (amount_join -> name , strlen (amount_join -> name ));
488- explicit_bzero (amount_join , sizeof (* amount_join ));
505+ flist_remove ((s_flist_node * * ) & ui_ctx -> amount .joins ,
506+ (s_flist_node * ) amount_join ,
507+ (f_list_node_del ) delete_amount_join );
489508 return true;
490509}
491510
@@ -730,7 +749,18 @@ bool ui_712_init(void) {
730749 * Deinit function that simply unsets the struct pointer to NULL
731750 */
732751void ui_712_deinit (void ) {
733- ui_ctx = NULL ;
752+ if (ui_ctx != NULL ) {
753+ app_mem_free (ui_ctx );
754+ if (ui_ctx -> filters_crc != NULL )
755+ flist_clear ((s_flist_node * * ) & ui_ctx -> filters_crc ,
756+ (f_list_node_del ) & delete_filter_crc );
757+ if (ui_ctx -> ui_pairs != NULL )
758+ flist_clear ((s_flist_node * * ) & ui_ctx -> ui_pairs , (f_list_node_del ) & delete_ui_pair );
759+ if (ui_ctx -> amount .joins != NULL )
760+ flist_clear ((s_flist_node * * ) & ui_ctx -> amount .joins ,
761+ (f_list_node_del ) & delete_amount_join );
762+ ui_ctx = NULL ;
763+ }
734764}
735765
736766/**
@@ -1005,7 +1035,7 @@ void ui_712_delete_pairs(size_t keep) {
10051035 size = flist_size ((s_flist_node * * ) & ui_ctx -> ui_pairs );
10061036 if (size > 0 ) {
10071037 while (size > keep ) {
1008- flist_pop_front ((s_flist_node * * ) & ui_ctx -> ui_pairs , NULL );
1038+ flist_pop_front ((s_flist_node * * ) & ui_ctx -> ui_pairs , ( f_list_node_del ) & delete_ui_pair );
10091039 size -= 1 ;
10101040 }
10111041 }
0 commit comments