swresample/swresample: Check count before memcpy()

Fixes undefined operation
Fixes part of 668007-media

Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-12-10 01:52:56 +01:00
parent 8258e36385
commit b3928a1cc6
1 changed files with 2 additions and 2 deletions

View File

@ -413,9 +413,9 @@ int swri_realloc_audio(AudioData *a, int count){
return AVERROR(ENOMEM);
for(i=0; i<a->ch_count; i++){
a->ch[i]= a->data + i*(a->planar ? countb : a->bps);
if(a->planar) memcpy(a->ch[i], old.ch[i], a->count*a->bps);
if(a->count && a->planar) memcpy(a->ch[i], old.ch[i], a->count*a->bps);
}
if(!a->planar) memcpy(a->ch[0], old.ch[0], a->count*a->ch_count*a->bps);
if(a->count && !a->planar) memcpy(a->ch[0], old.ch[0], a->count*a->ch_count*a->bps);
av_freep(&old.data);
a->count= count;