summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2020-06-24 10:30:14 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-09-05 18:02:41 +0200
commit6a1e58094e5ecafb3ec6358f428f511baf643dcf (patch)
tree48f03cb3398ed6ea35edeeb328902ec7b454d702
parent69a67a7f04fc5c0e36a290ad7a3e7afb4e801083 (diff)
downloadmate-settings-daemon-6a1e58094e5ecafb3ec6358f428f511baf643dcf.tar.bz2
mate-settings-daemon-6a1e58094e5ecafb3ec6358f428f511baf643dcf.tar.xz
a11y-keyboard: Add sanity checks on beep sequence preferences
-rw-r--r--plugins/a11y-keyboard/msd-a11y-keyboard-manager.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c
index 06e8586..76dbc75 100644
--- a/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c
+++ b/plugins/a11y-keyboard/msd-a11y-keyboard-manager.c
@@ -991,13 +991,16 @@ beep_sequence (MsdA11yKeyboardManager *manager,
if (count > 1) {
BeepSequenceData *data = g_malloc (sizeof *data);
- data->display = display;
- data->count = count - 1;
+ /* don't allow more than 8 beeps total, nor a delay outside
+ * the range 50ms-5s: anything outside this is not very
+ * reasonable and is more likely to be a broken setting,
+ * and we don't want to be beeping forever. */
+ g_warn_if_fail (count <= 8);
+ g_warn_if_fail (delay >= 50 && delay <= 5000);
- /* don't allow a delay below 50ms, it doesn't make much sense
- * anyway and is more likely to be a broken setting */
- g_warn_if_fail (delay >= 50);
- delay = MAX (delay, 50);
+ data->display = display;
+ data->count = MIN (8, count) - 1;
+ delay = CLAMP (delay, 50, 5000);
g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) delay,
on_beep_dequence_timeout, data, g_free);