diff options
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 165c3b9b43..b9d4bd6b15 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c | |||
@@ -398,13 +398,15 @@ const char *get_radio_token(struct wps_token *token, int preset_offset, | |||
398 | case WPS_TOKEN_PRESET_NAME: | 398 | case WPS_TOKEN_PRESET_NAME: |
399 | case WPS_TOKEN_PRESET_FREQ: | 399 | case WPS_TOKEN_PRESET_FREQ: |
400 | { | 400 | { |
401 | int preset = radio_current_preset() + preset_offset; | 401 | int preset_count = radio_preset_count(); |
402 | if (radio_preset_count() == 0 || preset == -1) | 402 | int cur_preset = radio_current_preset(); |
403 | if (preset_count == 0 || cur_preset < 0) | ||
403 | return NULL; | 404 | return NULL; |
404 | /* make sure its in the valid range */ | 405 | int preset = cur_preset + preset_offset; |
406 | /* make sure it's in the valid range */ | ||
405 | while (preset < 0) | 407 | while (preset < 0) |
406 | preset += radio_preset_count(); | 408 | preset += preset_count; |
407 | preset %= radio_preset_count(); | 409 | preset %= preset_count; |
408 | if (token->type == WPS_TOKEN_PRESET_NAME) | 410 | if (token->type == WPS_TOKEN_PRESET_NAME) |
409 | { | 411 | { |
410 | snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name); | 412 | snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name); |