Browse Source

dynamicoverlay: Fix memory leak when updating pictures

In exec_DataSharedMem() memory is allocated via the call to picture_New().
This memory is correctly freed via picture_Release() if an error occurs,
but if no error occurs and the function proceeds normally, the memory is
never freed. When the DataSharedMem routine is called repeatedly (e.g.,
to update a picture continuously), this leak accumulates very quickly.
pull/138/head
Alex Chernyakov 4 years ago
committed by Jean-Baptiste Kempf
parent
commit
41c1d1a9ee
  1. 6
      modules/spu/dynamicoverlay/dynamicoverlay_commands.c

6
modules/spu/dynamicoverlay/dynamicoverlay_commands.c

@ -58,12 +58,15 @@ overlay_t *OverlayCreate( void )
0, 0, 1, 1 );
p_ovl->p_fontstyle = text_style_Create( STYLE_NO_DEFAULTS );
p_ovl->data.p_text = NULL;
p_ovl->data.p_pic = NULL;
return p_ovl;
}
int OverlayDestroy( overlay_t *p_ovl )
{
if( p_ovl->data.p_pic != NULL )
picture_Release( p_ovl->data.p_pic );
free( p_ovl->data.p_text );
text_style_Delete( p_ovl->p_fontstyle );
@ -492,6 +495,9 @@ static int exec_DataSharedMem( filter_t *p_filter,
uint8_t *p_data, *p_in;
size_t i_neededsize = 0;
if( p_ovl->data.p_pic != NULL )
picture_Release( p_ovl->data.p_pic );
p_ovl->data.p_pic = picture_New( p_params->fourcc,
p_params->i_width, p_params->i_height,
1, 1 );

Loading…
Cancel
Save