[vlc-devel] [PATCH] mkv: fixed broken locking mechanism

Filip Roséen filip at videolabs.io
Fri Mar 18 19:30:02 CET 2016


A temporary object (ie. an object without a name) is created in the
expression in which it is introduced, and destroyed immediately after.

This means that the previous code did not lock p_sys->lock_demuxer for
the remaining duration of the function "Demux", but instead _only_
during the expression in which the temporary "vlc_mutex_locker" was
constructed (ie. the locking and unlocking happened on that line).

This patch fixes the issue by giving the previously unnamed object a
name (binding its lifetime to the current scope).
---
 modules/demux/mkv/mkv.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 41da7e4..f6e29c2 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -710,7 +710,7 @@ static int Demux( demux_t *p_demux)
 {
     demux_sys_t        *p_sys = p_demux->p_sys;
 
-    vlc_mutex_locker( &p_sys->lock_demuxer );
+    vlc_mutex_locker demux_lock ( &p_sys->lock_demuxer );
 
     virtual_segment_c  *p_vsegment = p_sys->p_current_vsegment;
 
-- 
2.7.3



More information about the vlc-devel mailing list