A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

mask_select guard against null pointers

Change-Id: I83d246c13d22c1e76a55cbfdd20dcc955eb556ec

authored by

William Wilgus and committed by
William Wilgus
1fd190d0 36e48a8b

+35 -27
+35 -27
apps/gui/mask_select.c
··· 79 79 while (i < root->children_count) 80 80 { 81 81 struct child *this = &root->children[i]; 82 - if (this->state == SELECTED) 83 - mask |= this->key_value; 82 + if (this) 83 + { 84 + if (this->state == SELECTED) 85 + mask |= this->key_value; 84 86 85 - else if (this->state == EXPANDED) 86 - mask = calculate_mask_r(this->category, mask); 87 + else if (this->state == EXPANDED) 88 + mask = calculate_mask_r(this->category, mask); 89 + } 87 90 i++; 88 91 } 89 92 return mask; ··· 97 100 for (i=0; i<start->children_count; i++) 98 101 { 99 102 struct child *foo = &start->children[i]; 100 - if (foo->state == EXPANDED) 103 + if (foo && foo->state == EXPANDED) 101 104 count += count_items(foo->category); 102 105 count++; 103 106 } ··· 120 123 return foo; 121 124 } 122 125 i++; 123 - if (foo->state == EXPANDED) 126 + if (foo && foo->state == EXPANDED) 124 127 { 125 128 struct child *bar = find_index(foo->category, index - i, parent); 126 129 if (bar) ··· 141 144 struct category *parent; 142 145 struct child *this = find_index(root, list->selected_item, &parent); 143 146 144 - if (action == ACTION_STD_OK) 147 + if (action == ACTION_STD_OK && this) 145 148 { 146 149 switch (this->state) 147 150 { ··· 194 197 for(int i = 0; i <= parent->depth; i++) 195 198 strcat(buffer, "\t\0"); 196 199 197 - /* state of selection needs icons so if icons are disabled use text*/ 198 - if (!global_settings.show_icons) 199 - { 200 - if (this->state == SELECTED) 201 - strcat(buffer, "+\0"); 202 - else 203 - strcat(buffer," \0"); 204 - } 205 - strlcat(buffer, P2STR((const unsigned char *)this->name), buffer_len); 206 - 200 + if (this) 201 + { 202 + /* state of selection needs icons so if icons are disabled use text*/ 203 + if (!global_settings.show_icons) 204 + { 205 + if (this->state == SELECTED) 206 + strcat(buffer, "+\0"); 207 + else 208 + strcat(buffer," \0"); 209 + } 210 + strlcat(buffer, P2STR((const unsigned char *)this->name), buffer_len); 211 + } 207 212 return buffer; 208 213 } 209 214 ··· 212 217 struct category *root = (struct category*)data; 213 218 struct category *parent; 214 219 struct child *this = find_index(root, selected_item , &parent); 215 - if (global_settings.talk_menu) 220 + if (global_settings.talk_menu && this) 216 221 { 217 222 long id = P2ID((const unsigned char *)(this->name)); 218 223 if(id>=0) ··· 234 239 struct category *parent; 235 240 struct child *this = find_index(root, selected_item, &parent); 236 241 237 - switch (this->state) 242 + if (this) 238 243 { 239 - case SELECTED: 240 - return Icon_Submenu; 241 - case COLLAPSED: 242 - return Icon_NOICON; 243 - case EXPANDED: 244 - return Icon_Submenu_Entered; 245 - default: 246 - return Icon_NOICON; 244 + switch (this->state) 245 + { 246 + case SELECTED: 247 + return Icon_Submenu; 248 + case COLLAPSED: 249 + return Icon_NOICON; 250 + case EXPANDED: 251 + return Icon_Submenu_Entered; 252 + default: 253 + return Icon_NOICON; 254 + } 247 255 } 248 256 return Icon_NOICON; 249 257 }