[vlc-devel] [PATCH] MKV: fix a memory leak

Steve Lhomme robUx4 at videolabs.io
Mon Mar 16 15:13:09 CET 2015


---
 modules/demux/mkv/mkv.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 58879f7..730c85d 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -192,11 +192,10 @@ static int Open( vlc_object_t * p_this )
                             // test whether this file belongs to our family
                             const uint8_t *p_peek;
                             bool          file_ok = false;
-#warning Memory leak!
-                            std::string   s_url = vlc_path2uri( s_filename.c_str(), "file" );
+                            char          *psz_url = vlc_path2uri( s_filename.c_str(), "file" );
                             stream_t      *p_file_stream = stream_UrlNew(
                                                             p_demux,
-                                                            s_url.c_str() );
+                                                            psz_url );
                             /* peek the begining */
                             if( p_file_stream &&
                                 stream_Peek( p_file_stream, &p_peek, 4 ) >= 4
@@ -230,6 +229,7 @@ static int Open( vlc_object_t * p_this )
                                 }
                                 msg_Dbg( p_demux, "the file '%s' cannot be opened", s_filename.c_str() );
                             }
+                            free( psz_url );
                         }
                     }
                 }
-- 
2.3.2




More information about the vlc-devel mailing list