Commit e4169612 authored by Justin Ruggles's avatar Justin Ruggles

apedec: av_fast_malloc() instead of av_realloc()

av_realloc() does not guarantee alignment, which is required for
DSPContext.bswap_buf().
parent 0759c8eb
...@@ -155,6 +155,7 @@ typedef struct APEContext { ...@@ -155,6 +155,7 @@ typedef struct APEContext {
uint8_t *data; ///< current frame data uint8_t *data; ///< current frame data
uint8_t *data_end; ///< frame data end uint8_t *data_end; ///< frame data end
int data_size; ///< frame data allocated size
const uint8_t *ptr; ///< current position in frame data const uint8_t *ptr; ///< current position in frame data
int error; int error;
...@@ -171,6 +172,8 @@ static av_cold int ape_decode_close(AVCodecContext *avctx) ...@@ -171,6 +172,8 @@ static av_cold int ape_decode_close(AVCodecContext *avctx)
av_freep(&s->filterbuf[i]); av_freep(&s->filterbuf[i]);
av_freep(&s->data); av_freep(&s->data);
s->data_size = 0;
return 0; return 0;
} }
...@@ -826,7 +829,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, ...@@ -826,7 +829,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
if(!s->samples){ if(!s->samples){
uint32_t nblocks, offset; uint32_t nblocks, offset;
void *tmp_data;
int buf_size; int buf_size;
if (!avpkt->size) { if (!avpkt->size) {
...@@ -843,10 +845,9 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, ...@@ -843,10 +845,9 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
"extra bytes at the end will be skipped.\n"); "extra bytes at the end will be skipped.\n");
} }
tmp_data = av_realloc(s->data, buf_size); av_fast_malloc(&s->data, &s->data_size, buf_size);
if (!tmp_data) if (!s->data)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
s->data = tmp_data;
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2); s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
s->ptr = s->data; s->ptr = s->data;
s->data_end = s->data + buf_size; s->data_end = s->data + buf_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment