afk: Fix a NULL pointer dereference in adfk_epic_send()

Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
Janne Grunau 2023-08-30 23:13:02 +02:00 committed by Hector Martin
parent 76fbc77ad2
commit a4c4b8cd99

View file

@ -479,11 +479,13 @@ int afk_epic_command(afk_epic_ep_t *epic, int channel, u16 sub_type, void *txbuf
return rcmd->retcode; // should be negative already
}
assert(*rxsize >= rcmd->rxlen);
*rxsize = rcmd->rxlen;
if (rxsize) {
assert(*rxsize >= rcmd->rxlen);
*rxsize = rcmd->rxlen;
if (rxsize && *rxsize && rcmd->rxbuf)
memcpy(rxbuf, epic->rxbuf.bfr, *rxsize);
if (*rxsize && rcmd->rxbuf)
memcpy(rxbuf, epic->rxbuf.bfr, *rxsize);
}
afk_epic_rx_ack(epic);