[FFmpeg-cvslog] swresample/swresample: Check count before memcpy()

Michael Niedermayer git at videolan.org
Sat Dec 10 03:46:50 EET 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Dec 10 01:52:56 2016 +0100| [b3928a1cc65462a72fea538fcf082cbc8f373e37] | committer: Michael Niedermayer

swresample/swresample: Check count before memcpy()

Fixes undefined operation
Fixes part of 668007-media

Found-by: Matt Wolenetz <wolenetz at google.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3928a1cc65462a72fea538fcf082cbc8f373e37
---

 libswresample/swresample.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 0ef4dea..dea6139 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -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;
 



More information about the ffmpeg-cvslog mailing list