forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #5887 from ogniK5377/lm-fix

lm: Fix ReadLeb128
This commit is contained in:
bunnei 2021-02-07 10:25:56 -08:00 committed by GitHub
commit 230e71b255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -143,17 +143,19 @@ private:
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
} }
u32 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) { u64 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) {
u32 result{}; u64 result{};
u32 shift{}; u32 shift{};
do {
result |= (data[offset] & 0x7f) << shift; for (std::size_t i = 0; i < sizeof(u64); i++) {
const auto v = data[offset];
result |= (static_cast<u64>(v & 0x7f) << shift);
shift += 7; shift += 7;
offset++; offset++;
if (offset >= data.size()) { if (offset >= data.size() || ((v & 0x80) == 0)) {
break; break;
} }
} while ((data[offset] & 0x80) != 0); }
return result; return result;
} }
@ -262,7 +264,7 @@ private:
switch (entry.severity) { switch (entry.severity) {
case LogSeverity::Trace: case LogSeverity::Trace:
LOG_DEBUG(Service_LM, "LogManager DEBUG ({}):\n{}", DestinationToString(destination), LOG_DEBUG(Service_LM, "LogManager TRACE ({}):\n{}", DestinationToString(destination),
output_log); output_log);
break; break;
case LogSeverity::Info: case LogSeverity::Info: