[vlc-commits] [Git][videolan/vlc][3.0.x] dynamicoverlay: Fix memory leak when updating pictures

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Aug 11 06:27:46 UTC 2022



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
5d8eed50 by Alex Chernyakov at 2022-08-11T05:21:06+00:00
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.

(cherry picked from commit 41c1d1a9eee6f580273cafff30e01abdf3d5ad2d)

- - - - -


1 changed file:

- modules/spu/dynamicoverlay/dynamicoverlay_commands.c


Changes:

=====================================
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 );
 
@@ -482,6 +485,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 );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/5d8eed501f537b29a7f9e3f9490c7215b4df36e4

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/5d8eed501f537b29a7f9e3f9490c7215b4df36e4
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list