mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-30 11:22:14 +00:00
Improve handling allocated buffers in Xan decoder
Originally committed as revision 20899 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
2628f515fe
commit
0080402d36
@ -76,10 +76,14 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
s->buffer1_size = avctx->width * avctx->height;
|
s->buffer1_size = avctx->width * avctx->height;
|
||||||
s->buffer1 = av_malloc(s->buffer1_size);
|
s->buffer1 = av_malloc(s->buffer1_size);
|
||||||
|
if (!s->buffer1)
|
||||||
|
return -1;
|
||||||
s->buffer2_size = avctx->width * avctx->height;
|
s->buffer2_size = avctx->width * avctx->height;
|
||||||
s->buffer2 = av_malloc(s->buffer2_size + 130);
|
s->buffer2 = av_malloc(s->buffer2_size + 130);
|
||||||
if (!s->buffer1 || !s->buffer2)
|
if (!s->buffer2) {
|
||||||
|
av_freep(&s->buffer1);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -405,8 +409,8 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
|
|||||||
if (s->current_frame.data[0])
|
if (s->current_frame.data[0])
|
||||||
avctx->release_buffer(avctx, &s->current_frame);
|
avctx->release_buffer(avctx, &s->current_frame);
|
||||||
|
|
||||||
av_free(s->buffer1);
|
av_freep(&s->buffer1);
|
||||||
av_free(s->buffer2);
|
av_freep(&s->buffer2);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user