Showing the changes to src/vm/module_reader.cpp (1 of 1 file). Show all
Unified · Split
| @@ -51,7 +51,7 @@ namespace · 50 unmodified lines | ||
| 51 | 51 | // Read the next operand as defined in the Dis VM specification. |
| 52 | 52 | std::tuple<bool, operand_t> read_next_operand(util::buffered_reader_t &reader) |
| 53 | 53 | { |
| 54 | − auto result = operand_t{ 0 }; | |
| 54 | + operand_t result; | |
| 55 | 55 | |
| 56 | 56 | // Converting stack allocation to buffer since max size of operand is a machine word |
| 57 | 57 | byte_t buffer[sizeof(result)]; |
| @@ -59,16 +59,16 @@ namespace · 1 unmodified line | ||
| 59 | 59 | if (!reader.get_next_bytes(1, buffer)) |
| 60 | 60 | return std::make_tuple(false, 0); |
| 61 | 61 | |
| 62 | − switch (buffer[0] & 0xc0) | |
| 62 | + result = buffer[0]; | |
| 63 | + switch (result & 0xc0) | |
| 63 | 64 | { |
| 64 | 65 | case 0x00: |
| 65 | 66 | // 1 byte operand |
| 66 | − result = buffer[0]; | |
| 67 | 67 | break; |
| 68 | 68 | |
| 69 | 69 | case 0x40: |
| 70 | 70 | // 1 byte operand - Preserve sign |
| 71 | − result = buffer[0] | ~0x7f; | |
| 71 | + result |= ~0x7f; | |
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | 74 | case 0x80: |
| @@ -77,12 +77,12 @@ namespace · 2 unmodified lines | ||
| 77 | 77 | return std::make_tuple(false, 0); |
| 78 | 78 | |
| 79 | 79 | // Preserve sign |
| 80 | − if ((buffer[0] & 0x20) != 0) | |
| 81 | − buffer[0] |= ~0x3f; | |
| 80 | + if ((result & 0x20) != 0) | |
| 81 | + result |= ~0x3f; | |
| 82 | 82 | else |
| 83 | − buffer[0] &= 0x3f; | |
| 83 | + result &= 0x3f; | |
| 84 | 84 | |
| 85 | − result = (buffer[0] << 8); | |
| 85 | + result = (result << 8); | |
| 86 | 86 | result |= buffer[1]; |
| 87 | 87 | break; |
| 88 | 88 | |
| @@ -92,12 +92,12 @@ namespace · 3 unmodified lines | ||
| 92 | 92 | return std::make_tuple(false, 0); |
| 93 | 93 | |
| 94 | 94 | // Preserve sign |
| 95 | − if ((buffer[0] & 0x20) != 0) | |
| 96 | − buffer[0] |= ~0x3f; | |
| 95 | + if ((result & 0x20) != 0) | |
| 96 | + result |= ~0x3f; | |
| 97 | 97 | else |
| 98 | − buffer[0] &= 0x3f; | |
| 98 | + result &= 0x3f; | |
| 99 | 99 | |
| 100 | − result = (buffer[0] << 24); | |
| 100 | + result = (result << 24); | |
| 101 | 101 | result |= (buffer[1] << 16); |
| 102 | 102 | result |= (buffer[2] << 8); |
| 103 | 103 | result |= buffer[3]; |