[vlc-commits] picture: add assertion against double free

Rémi Denis-Courmont git at videolan.org
Sat Jul 6 13:37:26 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul  4 23:12:44 2013 +0300| [36a00fd73b9348ce4467c1911e947f7949d5d4ac] | committer: Rémi Denis-Courmont

picture: add assertion against double free

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

 src/misc/picture.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index 093d7c0..60b8821 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -266,8 +266,12 @@ picture_t *picture_Hold( picture_t *p_picture )
 
 void picture_Release( picture_t *p_picture )
 {
-    if( vlc_atomic_dec( &p_picture->gc.refcount ) == 0 &&
-        p_picture->gc.pf_destroy )
+    uintptr_t refs = vlc_atomic_dec( &p_picture->gc.refcount );
+    assert( refs != (uintptr_t)-1 );
+    if( refs > 0 )
+        return;
+
+    if( p_picture->gc.pf_destroy != NULL )
         p_picture->gc.pf_destroy( p_picture );
 }
 



More information about the vlc-commits mailing list