summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-06-07 00:22:44 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-06-07 00:25:48 -0400
commit4829c2c8940db72e3336d122293b0760ee8e1585 (patch)
tree393e49b729139de73186879de5e7685703d6086e /apps/settings.c
parentdbdcd8425a2ec2edb1c2c3ec8322723765b14da6 (diff)
downloadrockbox-4829c2c8940db72e3336d122293b0760ee8e1585.tar.gz
rockbox-4829c2c8940db72e3336d122293b0760ee8e1585.zip
[coverity] settings.c int_to_string() string_to_int() guard NULL deref
Change-Id: I442b574ca27cf154697202a9fce7628cbcb6752d
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/settings.c b/apps/settings.c
index b281646686..dc3fede588 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -259,7 +259,7 @@ bool cfg_string_to_int(const struct settings_list *setting, int* out, const char
259 size_t len = strlen(str); 259 size_t len = strlen(str);
260 int index = 0; 260 int index = 0;
261 261
262 while (true) 262 while (ptr)
263 { 263 {
264 if (!strncmp(ptr, str, len)) 264 if (!strncmp(ptr, str, len))
265 { 265 {
@@ -283,6 +283,8 @@ bool cfg_string_to_int(const struct settings_list *setting, int* out, const char
283 ptr++; 283 ptr++;
284 index++; 284 index++;
285 } 285 }
286 logf("%s() bad setting\n", __func__);
287 return false;
286} 288}
287 289
288/** 290/**
@@ -471,7 +473,7 @@ bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf,
471 if (setting->flags & F_TABLE_SETTING) 473 if (setting->flags & F_TABLE_SETTING)
472 values = setting->table_setting->values; 474 values = setting->table_setting->values;
473 475
474 while (true) 476 while (ptr)
475 { 477 {
476 if ((values && values[index] == val) || 478 if ((values && values[index] == val) ||
477 (!values && index == val)) 479 (!values && index == val))
@@ -494,6 +496,8 @@ bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf,
494 ptr++; 496 ptr++;
495 index++; 497 index++;
496 } 498 }
499 logf("%s() bad setting\n", __func__);
500 return false;
497} 501}
498 502
499void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len) 503void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len)