[vlc-devel] [PATCH 01/20] mkv: added warning regarding undefined-behavior

Filip Roséen filip at videolabs.io
Fri Mar 4 17:03:59 CET 2016


The workaround currently present in the codebase is undefined-behavior
since the dynamic type of the object in question is not the one used in
the `static_cast`.

In short nothing guarantees that the vtable for the different types look
the same, and as such this is very dangerous.

We should probably supply a patch upstream if the bug is still present
in their code.
---
 modules/demux/mkv/Ebml_parser.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/demux/mkv/Ebml_parser.cpp b/modules/demux/mkv/Ebml_parser.cpp
index 0561ad1..5a5f18b 100644
--- a/modules/demux/mkv/Ebml_parser.cpp
+++ b/modules/demux/mkv/Ebml_parser.cpp
@@ -208,7 +208,7 @@ EbmlElement *EbmlParser::Get( int n_call )
             if( !mb_keep )
             {
                 if( MKV_IS_ID( p_prev, KaxBlockVirtual ) )
-                    static_cast<KaxBlockVirtualWorkaround*>(p_prev)->Fix();
+                    static_cast<KaxBlockVirtualWorkaround*>(p_prev)->Fix(); // !! WARNING : TODO !! this is undefined-behavior
                 delete p_prev;
             }
             mb_keep = false;
-- 
2.7.2



More information about the vlc-devel mailing list