summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Morph2023-03-07 22:42:32 -0500
committerGravatar GitHub2023-03-07 22:42:32 -0500
commita3ffea6a646ac1945ac7f01d401c7ae7b670b5a8 (patch)
tree26997bf1cf3b42d8e187923278357c8d774b5d0c /src/core
parentMerge pull request #9920 from liamwhite/constexpr-bit-cast (diff)
parentkernel: avoid signed overflow UB on MSVC (diff)
downloadyuzu-a3ffea6a646ac1945ac7f01d401c7ae7b670b5a8.tar.gz
yuzu-a3ffea6a646ac1945ac7f01d401c7ae7b670b5a8.tar.xz
yuzu-a3ffea6a646ac1945ac7f01d401c7ae7b670b5a8.zip
Merge pull request #9918 from liamwhite/fwrapv
kernel: avoid signed overflow UB on MSVC
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/k_resource_limit.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp
index b9d22b414..626517619 100644
--- a/src/core/hle/kernel/k_resource_limit.cpp
+++ b/src/core/hle/kernel/k_resource_limit.cpp
@@ -2,6 +2,7 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "common/assert.h" 4#include "common/assert.h"
5#include "common/overflow.h"
5#include "core/core.h" 6#include "core/core.h"
6#include "core/core_timing.h" 7#include "core/core_timing.h"
7#include "core/hle/kernel/k_resource_limit.h" 8#include "core/hle/kernel/k_resource_limit.h"
@@ -104,7 +105,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
104 ASSERT(current_hints[index] <= current_values[index]); 105 ASSERT(current_hints[index] <= current_values[index]);
105 106
106 // If we would overflow, don't allow to succeed. 107 // If we would overflow, don't allow to succeed.
107 if (current_values[index] + value <= current_values[index]) { 108 if (Common::WrappingAdd(current_values[index], value) <= current_values[index]) {
108 break; 109 break;
109 } 110 }
110 111