av_realloc() does not guarantee alignment, which is required for
DSPContext.bswap_buf().
---
libavcodec/apedec.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index fa50d61..71cd6ef 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -155,6 +155,7 @@ typedef struct APEContext {
uint8_t *data; ///< current frame data
uint8_t *data_end; ///< frame data end
+ int data_size; ///< frame data allocated size
const uint8_t *ptr; ///< current position in frame
data
int error;
@@ -171,6 +172,8 @@ static av_cold int ape_decode_close(AVCodecContext *avctx)
av_freep(&s->filterbuf[i]);
av_freep(&s->data);
+ s->data_size = 0;
+
return 0;
}
@@ -827,7 +830,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void
*data,
if(!s->samples){
uint32_t nblocks, offset;
- void *tmp_data;
if (!buf_size) {
*got_frame_ptr = 0;
@@ -838,10 +840,9 @@ static int ape_decode_frame(AVCodecContext *avctx, void
*data,
return AVERROR_INVALIDDATA;
}
- tmp_data = av_realloc(s->data, FFALIGN(buf_size, 4));
- if (!tmp_data)
+ av_fast_malloc(&s->data, &s->data_size, FFALIGN(buf_size, 4));
+ if (!s->data)
return AVERROR(ENOMEM);
- s->data = tmp_data;
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >>
2);
s->ptr = s->data;
s->data_end = s->data + buf_size;
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel