diff options
author | Jordi Ortiz <nenjordi@gmail.com> | 2012-05-22 13:18:17 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2012-05-22 13:27:06 +0200 |
commit | c89e428ed8c2c31396af2d18cab4342b7d82958f (patch) | |
tree | 80c5415e88971214643e8189c4a31adc28bda859 | |
parent | 3ea54294895c94e83a904085b0043cfbbf95eaa7 (diff) | |
download | ffmpeg-c89e428ed8c2c31396af2d18cab4342b7d82958f.tar.gz |
dwt: check malloc calls
Signed-off-by: Diego Biurrun <diego@biurrun.de>
-rw-r--r-- | libavcodec/dwt.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index f9577fd1bd..675644dbe6 100644 --- 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_width = line_width; buf->data_count = max_allocated_lines; 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]) { + for (i--; i >=0; i--) + av_free(buf->data_stack[i]); + av_free(buf->data_stack); + av_free(buf->line); + return AVERROR(ENOMEM); + } + } buf->data_stack_top = max_allocated_lines - 1; } |