aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-08-07 17:34:16 -0500
committerCharles Kerr <charles.kerr@canonical.com>2015-08-07 17:34:16 -0500
commit4b736bd0c19e85674add330ee6a00ddd6deb512a (patch)
tree5bad24f90f1ee3164b1c14f26ab27abc72f9786e
parent902577800836d04d91751f36ff4a1fd8b1eafeb3 (diff)
downloadayatana-indicator-sound-4b736bd0c19e85674add330ee6a00ddd6deb512a.tar.gz
ayatana-indicator-sound-4b736bd0c19e85674add330ee6a00ddd6deb512a.tar.bz2
ayatana-indicator-sound-4b736bd0c19e85674add330ee6a00ddd6deb512a.zip
in service's new user_recently_approved_loudness() method, fix a possible math underflow that could cause a false positive return value
-rw-r--r--src/service.vala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/service.vala b/src/service.vala
index dd0cc5a..73a331a 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -314,11 +314,12 @@ public class IndicatorSound.Service: Object {
private bool block_info_notifications = false;
private int64 loudness_approved_timestamp = 0;
- bool user_recently_approved_loudness() {
+ private bool user_recently_approved_loudness() {
int64 ttl_sec = this.settings.get_int("high-volume-acknowledgment-ttl");
int64 ttl_usec = ttl_sec * 1000000;
- int64 oldest_time_allowed = GLib.get_monotonic_time() - ttl_usec;
- return this.loudness_approved_timestamp >= oldest_time_allowed;
+ int64 now = GLib.get_monotonic_time();
+ return (this.loudness_approved_timestamp != 0)
+ && (this.loudness_approved_timestamp + ttl_usec >= now);
}
void update_notification () {