From 4b736bd0c19e85674add330ee6a00ddd6deb512a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 7 Aug 2015 17:34:16 -0500 Subject: in service's new user_recently_approved_loudness() method, fix a possible math underflow that could cause a false positive return value --- src/service.vala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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 () { -- cgit v1.2.3