summaryrefslogtreecommitdiff
path: root/libavcodec/flashsv.c
diff options
context:
space:
mode:
authorAlexandra Khirnova <alexandra.khirnova@gmail.com>2013-12-06 13:44:17 +0100
committerMartin Storsjö <martin@martin.st>2013-12-09 12:27:51 +0200
commit9b8d11a76ae7bca8bbb58abb822138f8b42c776c (patch)
tree702aed7eb0e0684c7a91fdac06a9981fb4333c49 /libavcodec/flashsv.c
parentd4f1188d1a662fed5347e70016da49e01563e8a8 (diff)
avcodec: Use av_reallocp where suitable
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/flashsv.c')
-rw-r--r--libavcodec/flashsv.c28
1 files changed, 14 insertions, 14 deletions
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",