1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

Merge pull request #11176 from bergzand/pr/nrf802154/undef_memcpy

nrf802154: don't call memcpy if iolist->iol_len==0
This commit is contained in:
Semjon Kerner 2019-03-25 08:09:59 +01:00 committed by GitHub
commit 253cf0f9fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -274,8 +274,12 @@ static int _send(netdev_t *dev, const iolist_t *iolist)
mutex_unlock(&_txlock);
return -EOVERFLOW;
}
memcpy(&txbuf[len + 1], iolist->iol_base, iolist->iol_len);
len += iolist->iol_len;
/* Check if there is data to copy, prevents undefined behaviour with
* memcpy when iolist->iol_base == NULL */
if (iolist->iol_len) {
memcpy(&txbuf[len + 1], iolist->iol_base, iolist->iol_len);
len += iolist->iol_len;
}
}
/* specify the length of the package. */