[vlc-devel] commit: Fixed by decrementing the i_refcount variable in the correct manner - ( Phil Roffe and David Grellscheid )

git version control git at videolan.org
Tue Apr 14 21:00:31 CEST 2009


vlc | branch: 0.9-bugfix | Phil Roffe and David Grellscheid <philip.roffe at durham.ac.uk> | Tue Apr 14 20:43:12 2009 +0200| [c6d84b4b38a0c142aee39a4c66a2f6430e03d27e] | committer: Antoine Cellerier 

Fixed by decrementing the i_refcount variable in the correct manner -
and therefore freeing the memory only when the i_refcount successfully
went to 0.

The problem was that i_refcount is an unsigned variable, and was being
decremented twice, once erroneously by mosaic_bridge, and then again in
the picture's original pf_release function. If i_refcount started at 1,
it wrapped to the maximum unsigned value rather than -1, failing the
refcount tests in the pf_release function.

Patch Authors: Phil Roffe and David Grellscheid

Signed-off-by: Antoine Cellerier <dionoea at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c6d84b4b38a0c142aee39a4c66a2f6430e03d27e
---

 modules/stream_out/mosaic_bridge.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index a28986c..bc5c402 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -79,8 +79,6 @@ static void ReleasePicture( picture_t *p_pic )
 {
     assert( p_pic );
 
-    if( --p_pic->i_refcount > 0 )
-        return;
 
     if( p_pic->p_sys )
     {
@@ -90,8 +88,11 @@ static void ReleasePicture( picture_t *p_pic )
     }
     else
     {
-        free( p_pic->p_data_orig );
-        free( p_pic );
+        if( --p_pic->i_refcount == 0 )
+        {
+            free( p_pic->p_data_orig );
+            free( p_pic );
+        }
     }
 }
 




More information about the vlc-devel mailing list