summaryrefslogtreecommitdiffstats
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
parentdbdcd8425a2ec2edb1c2c3ec8322723765b14da6 (diff)
downloadrockbox-4829c2c894.tar.gz
rockbox-4829c2c894.zip
[coverity] settings.c int_to_string() string_to_int() guard NULL deref
Change-Id: I442b574ca27cf154697202a9fce7628cbcb6752d
-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
size_t len = strlen(str);
int index = 0;
- while (true)
+ while (ptr)
{
if (!strncmp(ptr, str, len))
{
@@ -283,6 +283,8 @@ bool cfg_string_to_int(const struct settings_list *setting, int* out, const char
ptr++;
index++;
}
+ logf("%s() bad setting\n", __func__);
+ return false;
}
/**
@@ -471,7 +473,7 @@ bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf,
if (setting->flags & F_TABLE_SETTING)
values = setting->table_setting->values;
- while (true)
+ while (ptr)
{
if ((values && values[index] == val) ||
(!values && index == val))
@@ -494,6 +496,8 @@ bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf,
ptr++;
index++;
}
+ logf("%s() bad setting\n", __func__);
+ return false;
}
void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len)