Skip to content

Commit

Permalink
lavc: avoid invalid memcpy() in avcodec_default_release_buffer()
Browse files Browse the repository at this point in the history
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@mansr.com>
  • Loading branch information
mansr committed Dec 11, 2011
1 parent 3383a53 commit a09bb3b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libavcodec/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit a09bb3b

Please sign in to comment.