MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / DecodeUnsignedLeb128Checked

Function DecodeUnsignedLeb128Checked

Bcore/src/main/cpp/base/leb128.h:62–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62static inline bool DecodeUnsignedLeb128Checked(const uint8_t** data,
63 const void* end,
64 uint32_t* out) {
65 const uint8_t* ptr = *data;
66 if (ptr >= end) {
67 return false;
68 }
69 int result = *(ptr++);
70 if (UNLIKELY(result > 0x7f)) {
71 if (ptr >= end) {
72 return false;
73 }
74 int cur = *(ptr++);
75 result = (result & 0x7f) | ((cur & 0x7f) << 7);
76 if (cur > 0x7f) {
77 if (ptr >= end) {
78 return false;
79 }
80 cur = *(ptr++);
81 result |= (cur & 0x7f) << 14;
82 if (cur > 0x7f) {
83 if (ptr >= end) {
84 return false;
85 }
86 cur = *(ptr++);
87 result |= (cur & 0x7f) << 21;
88 if (cur > 0x7f) {
89 if (ptr >= end) {
90 return false;
91 }
92 // Note: We don't check to see if cur is out of range here,
93 // meaning we tolerate garbage in the four high-order bits.
94 cur = *(ptr++);
95 result |= cur << 28;
96 }
97 }
98 }
99 }
100 *data = ptr;
101 *out = static_cast<uint32_t>(result);
102 return true;
103}
104
105// Reads an unsigned LEB128 + 1 value. updating the given pointer to point
106// just past the end of the read value. This function tolerates

Callers 2

FindMethodNameFunction · 0.85
GetStringOrErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected