Skip to content

Commit 2ec737b

Browse files
committed
fix(machine): ensure the pointer is valid even when cLen is zero
1 parent 67ff0ed commit 2ec737b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/emulator/machine.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,13 @@ func (m *Machine) ReceiveCmioRequest() (uint8, uint16, []byte, error) {
333333
if err != nil {
334334
return
335335
}
336+
337+
// guard against empty `data`
338+
if cLen == 0 {
339+
cLen = 1
340+
}
336341
data = make([]byte, cLen)
342+
337343
err = newError(C.cm_receive_cmio_request(
338344
m.ptr,
339345
&cCmd,

0 commit comments

Comments
 (0)