Samples: Bluetooth: Fix bug in is_substring for broadcast sink
The is_substring did not work for true substrings, as it would always compare [0] to [0], so it would return false for the substring "BC" being in "ABC". Removed the tolower as it is not necessary and fixes the issue. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
01bd94ac4f
commit
e54902bdbe
1 changed files with 5 additions and 7 deletions
|
@ -618,14 +618,12 @@ static bool is_substring(const char *substr, const char *str)
|
|||
}
|
||||
|
||||
for (size_t pos = 0; pos < str_len; pos++) {
|
||||
if (tolower(substr[pos]) == tolower(str[pos])) {
|
||||
if (pos + sub_str_len > str_len) {
|
||||
return false;
|
||||
}
|
||||
if (pos + sub_str_len > str_len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncasecmp(substr, &str[pos], sub_str_len) == 0) {
|
||||
return true;
|
||||
}
|
||||
if (strncasecmp(substr, &str[pos], sub_str_len) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue