Skip to content

Commit 0f7e907

Browse files
Fix possible underflow in TokenResult (#1242)
Fix possible underflow in TokenResult Resolves: OLPEDGE-2628 Signed-off-by: Serhii Lozynskyi <[email protected]>
1 parent e508fc4 commit 0f7e907

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

olp-cpp-sdk-authentication/src/TokenResult.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ TokenResult::TokenResult(std::string access_token, time_t expiry_time,
3131
expiry_time_(expiry_time),
3232
http_status_(http_status),
3333
error_(std::move(error)) {
34-
expires_in_ = std::chrono::seconds(expiry_time_ - std::time(nullptr));
34+
const auto now = std::time(nullptr);
35+
expires_in_ =
36+
std::chrono::seconds(expiry_time_ > now ? (expiry_time_ - now) : 0);
3537
}
3638

3739
TokenResult::TokenResult(std::string access_token,

0 commit comments

Comments
 (0)