summaryrefslogtreecommitdiff
path: root/src/core/hle/service/lm
diff options
context:
space:
mode:
authorGravatar Chloe Marcec2021-02-07 23:52:56 +1100
committerGravatar Chloe Marcec2021-02-07 23:52:56 +1100
commit9d5a56a40b6f25548ebc364c590ab891c9bbe8ba (patch)
tree2b65ab7c6470520175317f99a0b93adbcc2cfe97 /src/core/hle/service/lm
parentMerge pull request #5885 from MerryMage/ring_buffer-granularity (diff)
downloadyuzu-9d5a56a40b6f25548ebc364c590ab891c9bbe8ba.tar.gz
yuzu-9d5a56a40b6f25548ebc364c590ab891c9bbe8ba.tar.xz
yuzu-9d5a56a40b6f25548ebc364c590ab891c9bbe8ba.zip
lm: Fix ReadLeb128
Fixes assertion on Bloodstained Ritual of the Night. We would over read sometimes, this is fixed by checking if the top bit is set in the first iteration. We also lock the loop off to be only the max size of the type we can fit. Finally we changed an incorrect print of "DEBUG" to "TRACE" to reflect the proper log severity
Diffstat (limited to 'src/core/hle/service/lm')
-rw-r--r--src/core/hle/service/lm/lm.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index 2a6d43d2a..7d7542fc2 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -143,17 +143,19 @@ private:
143 rb.Push(RESULT_SUCCESS); 143 rb.Push(RESULT_SUCCESS);
144 } 144 }
145 145
146 u32 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) { 146 u64 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) {
147 u32 result{}; 147 u64 result{};
148 u32 shift{}; 148 u32 shift{};
149 do { 149
150 result |= (data[offset] & 0x7f) << shift; 150 for (std::size_t i = 0; i < sizeof(u64); i++) {
151 const auto v = data[offset];
152 result |= (static_cast<u64>(v & 0x7f) << shift);
151 shift += 7; 153 shift += 7;
152 offset++; 154 offset++;
153 if (offset >= data.size()) { 155 if (offset >= data.size() || ((v & 0x80) == 0)) {
154 break; 156 break;
155 } 157 }
156 } while ((data[offset] & 0x80) != 0); 158 }
157 return result; 159 return result;
158 } 160 }
159 161
@@ -262,7 +264,7 @@ private:
262 264
263 switch (entry.severity) { 265 switch (entry.severity) {
264 case LogSeverity::Trace: 266 case LogSeverity::Trace:
265 LOG_DEBUG(Service_LM, "LogManager DEBUG ({}):\n{}", DestinationToString(destination), 267 LOG_DEBUG(Service_LM, "LogManager TRACE ({}):\n{}", DestinationToString(destination),
266 output_log); 268 output_log);
267 break; 269 break;
268 case LogSeverity::Info: 270 case LogSeverity::Info: