On 2012-02-01 11:13:54 -0500, Justin Ruggles wrote:
> On 01/31/2012 08:44 PM, Janne Grunau wrote:
> 
> > On 2012-02-01 02:21:35 +0100, Janne Grunau wrote:
> >> On 2012-01-31 11:40:16 -0500, Justin Ruggles wrote:
> >>> 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
> > 
> > [...]
> >>> @@ -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;
> >>
> >> ok
> > 
> > actually not unless buf_size is guaranteed to be a multiple of 4.
> 
> 
> I see what you mean, but that would really be a separate issue in the
> current code. Probably it should be:
> s->data_end = s->data + (buf_size & ~3);

that and there is a gap between the padding and the last bswapped
content if buf_size is not a multiple of 4.

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

Reply via email to