Skip to content

Commit f04fcb3

Browse files
authored
AccentColorManager: Prevent out of range access to themes array (#222)
1 parent dcc0de2 commit f04fcb3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Backends/AccentColorManager.vala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ public class SettingsDaemon.Backends.AccentColorManager : Object {
8585
private void update_accent_color () {
8686
Theme? new_theme = null;
8787
var prefers_accent_color = pantheon_accounts_service.prefers_accent_color;
88+
if (prefers_accent_color < 0 || prefers_accent_color - 1 >= themes.length) {
89+
critical ("Incorrect accent color in pantheon accounts service. color=%d", prefers_accent_color);
90+
return;
91+
}
92+
8893
if (prefers_accent_color == 0) {
8994
new_theme = get_dynamic_accent_color_theme_name ();
90-
} else if (prefers_accent_color < themes.length + 1) {
91-
new_theme = themes[prefers_accent_color - 1];
9295
} else {
93-
critical ("Incorrect accent color in pantheon accounts service");
94-
return;
96+
new_theme = themes[prefers_accent_color - 1];
9597
}
9698

9799
interface_settings.set_string ("gtk-theme", new_theme.stylesheet);

0 commit comments

Comments
 (0)