[vlc-commits] mkv: added warning regarding undefined-behavior

Filip Roséen git at videolan.org
Sat Mar 5 22:14:45 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Mar  4 17:03:59 2016 +0100| [4df0bba2679b306af75abf5e484216e50959886d] | committer: Jean-Baptiste Kempf

mkv: added warning regarding undefined-behavior

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.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 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;



More information about the vlc-commits mailing list