Update ReadByte()
@@ -205,19 +205,17 @@ namespace Iced.Intel {
internal uint ReadByte() {
uint instrLen = state.instructionLength;
- if (instrLen >= DecoderConstants.MaxInstructionLength) {
- state.flags |= StateFlags.IsInvalid;
- return 0;
- }
+ if (instrLen < DecoderConstants.MaxInstructionLength) {
uint b = (uint)reader.ReadByte();
Debug.Assert(b <= byte.MaxValue || b > int.MaxValue);
- if (b > byte.MaxValue) {
- state.flags |= StateFlags.IsInvalid;
- return 0;
- }
+ if (b <= byte.MaxValue) {
state.instructionLength = instrLen + 1;
return b;
}
+ }
+ state.flags |= StateFlags.IsInvalid;
+ return 0;
+ }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal uint ReadUInt16() => ReadByte() | (ReadByte() << 8);
