From 4b29daabd4d88c63c191be0f6d765f8dd52a26f3 Mon Sep 17 00:00:00 2001 From: Archi Date: Fri, 15 Dec 2023 14:20:58 +0100 Subject: [PATCH] Fix possible NRE --- ArchiSteamFarm/Steam/Bot.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index f971c55cb21ae..8d62ba199e32c 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -3293,9 +3293,11 @@ private async void OnPlayingSessionState(SteamUser.PlayingSessionStateCallback c } private async void OnRefreshTokensTimer(object? state = null) { - if (AccessTokenValidUntil.HasValue && (AccessTokenValidUntil.Value > DateTime.UtcNow.AddMinutes(MinimumAccessTokenValidityMinutes))) { + DateTime accessTokenValidUntil = AccessTokenValidUntil.GetValueOrDefault(); + + if ((accessTokenValidUntil > DateTime.MinValue) && (accessTokenValidUntil > DateTime.UtcNow.AddMinutes(MinimumAccessTokenValidityMinutes))) { // We don't need to refresh just yet - InitRefreshTokensTimer(AccessTokenValidUntil.Value); + InitRefreshTokensTimer(accessTokenValidUntil); } await RefreshWebSession().ConfigureAwait(false);