[FFmpeg-cvslog] lavc: avoid invalid memcpy() in avcodec_default_release_buffer()

Mans Rullgard git at videolan.org
Mon Dec 12 01:43:50 CET 2011


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Mon Dec  5 15:38:10 2011 +0000| [a09bb3ba5e018b81a659c199a84cd1d80c07d869] | committer: Mans Rullgard

lavc: avoid invalid memcpy() in avcodec_default_release_buffer()

When the buf and last pointers are equal, the FFSWAP() results
in an invalid call to memcpy() with same source and destination
on some targets.  Although assigning a struct to itself is valid
C99, gcc does not check for this before calling memcpy().
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667

Signed-off-by: Mans Rullgard <mans at mansr.com>

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

 libavcodec/utils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 04909cf..68fc525 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -509,7 +509,8 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
         avci->buffer_count--;
         last = &avci->buffer[avci->buffer_count];
 
-        FFSWAP(InternalBuffer, *buf, *last);
+        if (buf != last)
+            FFSWAP(InternalBuffer, *buf, *last);
     }
 
     for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {



More information about the ffmpeg-cvslog mailing list