Reads an unsigned LEB128 value, updating the given pointer to point just past the end of the read value. This function tolerates non-zero high-order bits in the fifth encoded byte.
| 31 | // just past the end of the read value. This function tolerates |
| 32 | // non-zero high-order bits in the fifth encoded byte. |
| 33 | static inline uint32_t DecodeUnsignedLeb128(const uint8_t** data) { |
| 34 | const uint8_t* ptr = *data; |
| 35 | int result = *(ptr++); |
| 36 | if (UNLIKELY(result > 0x7f)) { |
| 37 | int cur = *(ptr++); |
| 38 | result = (result & 0x7f) | ((cur & 0x7f) << 7); |
| 39 | if (cur > 0x7f) { |
| 40 | cur = *(ptr++); |
| 41 | result |= (cur & 0x7f) << 14; |
| 42 | if (cur > 0x7f) { |
| 43 | cur = *(ptr++); |
| 44 | result |= (cur & 0x7f) << 21; |
| 45 | if (cur > 0x7f) { |
| 46 | // Note: We don't check to see if cur is out of range here, |
| 47 | // meaning we tolerate garbage in the four high-order bits. |
| 48 | cur = *(ptr++); |
| 49 | result |= cur << 28; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | *data = ptr; |
| 55 | return static_cast<uint32_t>(result); |
| 56 | } |
| 57 | |
| 58 | static inline uint32_t DecodeUnsignedLeb128WithoutMovingCursor(const uint8_t* data) { |
| 59 | return DecodeUnsignedLeb128(&data); |
no outgoing calls
no test coverage detected