Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions x86/x86asm/avx.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func decodeAVX(src []byte, pos int, vex Prefix, vexIndex int, inst Inst, mode in

_ = evex_z // TODO: use zeroing mask if needed for output

if pos >= len(src) {
return inst, errors.New("truncated")
}
opbyte := src[pos]
pos++

Expand Down
5 changes: 5 additions & 0 deletions x86/x86asm/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func TestDecodeDoesNotCrash(t *testing.T) {
[]byte{},
[]byte{0xc5},
[]byte{0xc4},
// Streams ending exactly at the end of a VEX or EVEX prefix,
// leaving no opcode byte.
[]byte{0xc5, 0xfc},
[]byte{0xc4, 0xe2, 0x7d},
[]byte{0x62, 0xf1, 0x7c, 0x48},
}
for _, test := range cases {
_, err := Decode([]byte(test), 64) // the only goal is that this line does not panic
Expand Down