summaryrefslogtreecommitdiff
path: root/libavcodec/xan.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2009-12-19 17:04:30 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2009-12-19 17:04:30 +0000
commit0080402d36c23bfba44fde3a1d472295a15a09fb (patch)
tree59bcfa984c9b59fe5b0905431399d24cf04ff5e2 /libavcodec/xan.c
parent2628f515fefd16c75a610f494737731272c5b718 (diff)
downloadffmpeg-0080402d36c23bfba44fde3a1d472295a15a09fb.tar.gz
Improve handling allocated buffers in Xan decoder
Originally committed as revision 20899 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/xan.c')
-rw-r--r--libavcodec/xan.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index e0bd780095..c11f60deb3 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -76,10 +76,14 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
s->buffer1_size = avctx->width * avctx->height;
s->buffer1 = av_malloc(s->buffer1_size);
+ if (!s->buffer1)
+ return -1;
s->buffer2_size = avctx->width * avctx->height;
s->buffer2 = av_malloc(s->buffer2_size + 130);
- if (!s->buffer1 || !s->buffer2)
+ if (!s->buffer2) {
+ av_freep(&s->buffer1);
return -1;
+ }
return 0;
}
@@ -405,8 +409,8 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
if (s->current_frame.data[0])
avctx->release_buffer(avctx, &s->current_frame);
- av_free(s->buffer1);
- av_free(s->buffer2);
+ av_freep(&s->buffer1);
+ av_freep(&s->buffer2);
return 0;
}