fix: silence -Wunsafe-buffer-usage warning in GetPreferredLanguages() (#44333)
fix: use UNSAFE_BUFFERS macro in GetPreferredLanguages()
This commit is contained in:
parent
fff6ea438a
commit
e3e94d45ee
1 changed files with 4 additions and 1 deletions
|
@ -22,7 +22,10 @@ std::vector<std::string> GetPreferredLanguages() {
|
|||
DCHECK(languages); // A valid pointer is guaranteed.
|
||||
DCHECK(*languages); // At least one entry, "C", is guaranteed.
|
||||
|
||||
for (; *languages; ++languages) {
|
||||
// SAFETY: |g_get_language_names()| returns a glib-owned array
|
||||
// of const C strings, terminated by an empty string.
|
||||
// This loop is the correct way to walk through its return values.
|
||||
for (; *languages; UNSAFE_BUFFERS(++languages)) {
|
||||
if (strcmp(*languages, "C") != 0) {
|
||||
preferredLanguages.push_back(base::i18n::GetCanonicalLocale(*languages));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue