[vlc-commits] xml! fix potential memleak.

Rémi Duraffort git at videolan.org
Fri Jan 21 19:22:45 CET 2011


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Jan 21 19:22:12 2011 +0100| [c101ca179b62f5e7c9a7d824c879c49d7f1917f9] | committer: Rémi Duraffort

xml! fix potential memleak.

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

 modules/misc/xml/libxml.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/modules/misc/xml/libxml.c b/modules/misc/xml/libxml.c
index 70fef06..7cd55a4 100644
--- a/modules/misc/xml/libxml.c
+++ b/modules/misc/xml/libxml.c
@@ -149,16 +149,19 @@ static int ReaderOpen( vlc_object_t *p_this )
     xml_reader_sys_t *p_sys = malloc( sizeof( *p_sys ) );
     xmlTextReaderPtr p_libxml_reader;
 
+    if( unlikely(!p_sys) )
+        return VLC_ENOMEM;
+
     if( !xmlHasFeature( XML_WITH_THREAD ) )
+    {
+        free( p_sys );
         return VLC_EGENERIC;
+    }
 
     vlc_mutex_lock( &lock );
     xmlInitParser();
     vlc_mutex_unlock( &lock );
 
-    if( unlikely(!p_sys) )
-        return VLC_ENOMEM;
-
     p_libxml_reader = xmlReaderForIO( StreamRead, NULL, p_reader->p_stream,
                                       NULL, NULL, 0 );
     if( !p_libxml_reader )



More information about the vlc-commits mailing list