audio_buffer: fix some more theoretical UB

This may call memmove() with size==0 and a NULL data pointer. In
addition to this being UB with memmove(), I think it's UB to do
arithmetic on a NULL pointer too. Of course, this doesn't matter in
practice at all, and is just stupidity to torture programmers.
This commit is contained in:
wm4 2019-06-09 19:04:46 +02:00
parent fae31f39c7
commit 4e4949b4dc
1 changed files with 3 additions and 0 deletions

View File

@ -87,6 +87,9 @@ static void copy_planes(struct mp_audio_buffer *ab,
uint8_t **dst, int dst_offset, uint8_t **dst, int dst_offset,
uint8_t **src, int src_offset, int length) uint8_t **src, int src_offset, int length)
{ {
if (!length)
return;
for (int n = 0; n < ab->num_planes; n++) { for (int n = 0; n < ab->num_planes; n++) {
memmove((char *)dst[n] + dst_offset * ab->sstride, memmove((char *)dst[n] + dst_offset * ab->sstride,
(char *)src[n] + src_offset * ab->sstride, (char *)src[n] + src_offset * ab->sstride,