From e984f47873258b600fd88423f40e3cdaad179190 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 16 Jan 2013 17:52:55 -0500 Subject: [PATCH 1/3] libmp3lame: use the correct remaining buffer size when flushing CC:libav-stable@libav.org --- libavcodec/libmp3lame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 156665c0d6..2e501cac0b 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -217,7 +217,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } } else { lame_result = lame_encode_flush(s->gfp, s->buffer + s->buffer_index, - BUFFER_SIZE - s->buffer_index); + s->buffer_size - s->buffer_index); } if (lame_result < 0) { if (lame_result == -1) { From 486f0b0cfc800cd38ec06635630539431d296774 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 16 Jan 2013 18:10:57 -0500 Subject: [PATCH 2/3] png: use av_mallocz_array() for the zlib zalloc function Fixes valgrind uninitialized memory errors when decoding png. CC:libav-stable@libav.org --- libavcodec/png.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/png.c b/libavcodec/png.c index 70a080e29e..65d696476a 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -47,9 +47,7 @@ const uint8_t ff_png_pass_mask[NB_PASSES] = { void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size) { - if(items >= UINT_MAX / size) - return NULL; - return av_malloc(items * size); + return av_mallocz_array(items, size); } void ff_png_zfree(void *opaque, void *ptr) From 6327c10702922eabcb1c6170abd3f03d23ce4c51 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 8 Mar 2013 20:57:31 +0100 Subject: [PATCH 3/3] atomic: fix CAS with armcc. On the current code, armcc will fail with: "libavutil/atomic_gcc.h", line 52: Error: #2771: first argument must be a pointer to integer or enumeration type --- libavutil/atomic_gcc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavutil/atomic_gcc.h b/libavutil/atomic_gcc.h index 13713c82e0..9470e8e50b 100644 --- a/libavutil/atomic_gcc.h +++ b/libavutil/atomic_gcc.h @@ -21,6 +21,8 @@ #ifndef AVUTIL_ATOMIC_GCC_H #define AVUTIL_ATOMIC_GCC_H +#include + #include "atomic.h" #define avpriv_atomic_int_get atomic_int_get_gcc @@ -47,7 +49,13 @@ static inline int atomic_int_add_and_fetch_gcc(volatile int *ptr, int inc) static inline void *atomic_ptr_cas_gcc(void * volatile *ptr, void *oldval, void *newval) { +#ifdef __ARMCC_VERSION + // armcc will throw an error if ptr is not an integer type + volatile uintptr_t *tmp = (volatile uintptr_t*)ptr; + return (void*)__sync_val_compare_and_swap(tmp, oldval, newval); +#else return __sync_val_compare_and_swap(ptr, oldval, newval); +#endif } #endif /* AVUTIL_ATOMIC_GCC_H */