From 9b8d11a76ae7bca8bbb58abb822138f8b42c776c Mon Sep 17 00:00:00 2001 From: Alexandra Khirnova Date: Fri, 6 Dec 2013 13:44:17 +0100 Subject: avcodec: Use av_reallocp where suitable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/flashsv.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'libavcodec/flashsv.c') diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index a6e8dae7d2..de7979c976 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -296,13 +296,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* the block size could change between frames, make sure the buffer * is large enough, if not, get a larger one */ if (s->block_size < s->block_width * s->block_height) { - int tmpblock_size = 3 * s->block_width * s->block_height; + int tmpblock_size = 3 * s->block_width * s->block_height, err; - s->tmpblock = av_realloc(s->tmpblock, tmpblock_size); - if (!s->tmpblock) { + if ((err = av_reallocp(&s->tmpblock, tmpblock_size)) < 0) { + s->block_size = 0; av_log(avctx, AV_LOG_ERROR, "Cannot allocate decompression buffer.\n"); - return AVERROR(ENOMEM); + return err; } if (s->ver == 2) { s->deflate_block_size = calc_deflate_block_size(tmpblock_size); @@ -311,12 +311,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, "Cannot determine deflate buffer size.\n"); return -1; } - s->deflate_block = av_realloc(s->deflate_block, - s->deflate_block_size); - if (!s->deflate_block) { - av_log(avctx, AV_LOG_ERROR, - "Cannot allocate deflate buffer.\n"); - return AVERROR(ENOMEM); + if ((err = av_reallocp(&s->deflate_block, s->deflate_block_size)) < 0) { + s->block_size = 0; + av_log(avctx, AV_LOG_ERROR, "Cannot allocate deflate buffer.\n"); + return err; } } } @@ -340,11 +338,13 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* we care for keyframes only in Screen Video v2 */ s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); if (s->is_keyframe) { - s->keyframedata = av_realloc(s->keyframedata, avpkt->size); + int err; + if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0) + return err; memcpy(s->keyframedata, avpkt->data, avpkt->size); - s->blocks = av_realloc(s->blocks, - (v_blocks + !!v_part) * (h_blocks + !!h_part) * - sizeof(s->blocks[0])); + if ((err = av_reallocp(&s->blocks, (v_blocks + !!v_part) * + (h_blocks + !!h_part) * sizeof(s->blocks[0]))) < 0) + return err; } av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", -- cgit v1.2.3