Read an unsigned LEB128 value from buf, advance buf, return value. Sets ok = false and returns 0 on truncated input or overflow.
| 36 | /// Read an unsigned LEB128 value from buf, advance buf, return value. |
| 37 | /// Sets ok = false and returns 0 on truncated input or overflow. |
| 38 | uint64_t readULEB128(const uint8_t *& buf, const uint8_t * end, bool & ok) |
| 39 | { |
| 40 | uint64_t result = 0; |
| 41 | int shift = 0; |
| 42 | while (buf < end) |
| 43 | { |
| 44 | const uint8_t byte = *buf++; |
| 45 | result |= static_cast<uint64_t>(byte & 0x7fu) << shift; |
| 46 | if (!(byte & 0x80u)) |
| 47 | return result; |
| 48 | shift += 7; |
| 49 | if (shift >= 64) |
| 50 | { |
| 51 | ok = false; |
| 52 | return 0; |
| 53 | } |
| 54 | } |
| 55 | ok = false; |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | /// One parsed filename table from a `__llvm_covmap` header block. |
| 60 | struct FilenameTable |
no outgoing calls
no test coverage detected