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().

Signed-off-by: Mans Rullgard <[email protected]>
---
 libavcodec/utils.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c844399..df542a8 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++) {
-- 
1.7.8

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to