Just "dwt" is enough in the subject.

On Mon, May 21, 2012 at 10:48:55PM +0200, Jordi Ortiz wrote:
> --- a/libavcodec/dwt.c
> +++ b/libavcodec/dwt.c
> @@ -33,10 +33,24 @@ void ff_slice_buffer_init(slice_buffer *buf, int 
> line_count,
>      buf->line        = av_mallocz(sizeof(IDWTELEM *) * line_count);
> +    if (!buf->line)
> +        return AVERROR(ENOMEM);
>      buf->data_stack  = av_malloc(sizeof(IDWTELEM *) * max_allocated_lines);
> +    if (!buf->data_stack) {
> +        av_free(buf->line);
> +        return AVERROR(ENOMEM);
> +    }
>  
> -    for (i = 0; i < max_allocated_lines; i++)
> +    for (i = 0; i < max_allocated_lines; i++) {
>          buf->data_stack[i] = av_malloc(sizeof(IDWTELEM) * line_width);
> +        if (!buf->data_stack[i]) {
> +            while (i >= 0) {
> +                av_free(buf->data_stack[i]);
> +                i--;
> +            }
> +            return AVERROR(ENOMEM);

There's a fencepost error in the loop: You free the pointer for which
the malloc just failed, but you only need to free all previous ones.
You also need to free the two initially malloced pointers if a malloc
in the loop fails.

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

Reply via email to