diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-01-10 13:59:46 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-01-10 14:02:39 +0100 |
commit | 35e559ae32f22153198bb54a79015982403c704f (patch) | |
tree | 6b8ba69a9c087e73422ecc2ac11230564d96bb14 /libavcodec/cavs.c | |
parent | 6f838dee3cf86bf8b7196ef25bcce1cb4736a0c4 (diff) |
avcodec/cavs: Check for av_malloc* failure in ff_cavs_init_top_lines()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/cavs.c')
-rw-r--r-- | libavcodec/cavs.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index c0880e005f..83073901bc 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -751,7 +751,7 @@ int ff_cavs_init_pic(AVSContext *h) * this data has to be stored for one complete row of macroblocks * and this storage space is allocated here */ -void ff_cavs_init_top_lines(AVSContext *h) +int ff_cavs_init_top_lines(AVSContext *h) { /* alloc top line of predictors */ h->top_qp = av_mallocz(h->mb_width); @@ -767,6 +767,23 @@ void ff_cavs_init_top_lines(AVSContext *h) 4 * sizeof(cavs_vector)); h->col_type_base = av_mallocz(h->mb_width * h->mb_height); h->block = av_mallocz(64 * sizeof(int16_t)); + + if (!h->top_qp || !h->top_mv[0] || !h->top_mv[1] || !h->top_pred_Y || + !h->top_border_y || !h->top_border_u || !h->top_border_v || + !h->col_mv || !h->col_type_base || !h->block) { + av_freep(&h->top_qp); + av_freep(&h->top_mv[0]); + av_freep(&h->top_mv[1]); + av_freep(&h->top_pred_Y); + av_freep(&h->top_border_y); + av_freep(&h->top_border_u); + av_freep(&h->top_border_v); + av_freep(&h->col_mv); + av_freep(&h->col_type_base); + av_freep(&h->block); + return AVERROR(ENOMEM); + } + return 0; } av_cold int ff_cavs_init(AVCodecContext *avctx) |