mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
fix mem leak
patch by Daniel Kristjansson: [danielk cuymedia net] Original thread: [FFmpeg-devel] [PATCH] alloc_picture needs to free buffer when it's not going to use it Date: 07/20/2007 07:27 PM Originally committed as revision 9838 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
c7bf7a8267
commit
29d2dc59f9
@ -188,14 +188,13 @@ int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
|
|||||||
const int b8_array_size= s->b8_stride*s->mb_height*2;
|
const int b8_array_size= s->b8_stride*s->mb_height*2;
|
||||||
const int b4_array_size= s->b4_stride*s->mb_height*4;
|
const int b4_array_size= s->b4_stride*s->mb_height*4;
|
||||||
int i;
|
int i;
|
||||||
|
int r= -1;
|
||||||
|
|
||||||
if(shared){
|
if(shared){
|
||||||
assert(pic->data[0]);
|
assert(pic->data[0]);
|
||||||
assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
|
assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
|
||||||
pic->type= FF_BUFFER_TYPE_SHARED;
|
pic->type= FF_BUFFER_TYPE_SHARED;
|
||||||
}else{
|
}else{
|
||||||
int r;
|
|
||||||
|
|
||||||
assert(!pic->data[0]);
|
assert(!pic->data[0]);
|
||||||
|
|
||||||
r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
|
r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
|
||||||
@ -207,11 +206,13 @@ int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
|
|||||||
|
|
||||||
if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
|
if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
|
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
|
||||||
|
s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pic->linesize[1] != pic->linesize[2]){
|
if(pic->linesize[1] != pic->linesize[2]){
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
|
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
|
||||||
|
s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,6 +262,8 @@ int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail: //for the CHECKED_ALLOCZ macro
|
fail: //for the CHECKED_ALLOCZ macro
|
||||||
|
if(r>=0)
|
||||||
|
s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user