[vlc-commits] commit: skins2: fix memory leak (a malloc not paired with a free) ( Erwan Tulou )

git at videolan.org git at videolan.org
Sun May 9 23:37:36 CEST 2010


vlc/vlc-1.1 | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu May  6 15:42:03 2010 +0200| [1c05e50d0a9809a738050248b51649e6d35698be] | committer: Jean-Baptiste Kempf 

skins2: fix memory leak (a malloc not paired with a free)
(cherry picked from commit 4337a2d9b9e125f0619e1e7ffc390ce161d76284)

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

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

 modules/gui/skins2/commands/cmd_vars.hpp |   14 ++++++++++++--
 modules/gui/skins2/src/vlcproc.cpp       |    5 +----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_vars.hpp b/modules/gui/skins2/commands/cmd_vars.hpp
index c6f926e..c4e83c4 100644
--- a/modules/gui/skins2/commands/cmd_vars.hpp
+++ b/modules/gui/skins2/commands/cmd_vars.hpp
@@ -71,8 +71,18 @@ class CmdPlaytreeAppend: public CmdGeneric
 {
 public:
     CmdPlaytreeAppend( intf_thread_t *pIntf, playlist_add_t *p_add ):
-        CmdGeneric( pIntf ), m_pAdd( p_add ) { }
-    virtual ~CmdPlaytreeAppend() { }
+        CmdGeneric( pIntf ), m_pAdd( NULL )
+    {
+        if( p_add )
+        {
+            m_pAdd = new playlist_add_t;
+            *m_pAdd = *p_add;
+        }
+    }
+    virtual ~CmdPlaytreeAppend()
+    {
+        delete m_pAdd;
+    }
     virtual void execute();
     virtual string getType() const { return "playtree append"; }
 
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index bb95186..208a56f 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -287,10 +287,7 @@ int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
 {
     VlcProc *pThis = (VlcProc*)pParam;
 
-    playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
-                                                playlist_add_t ) ) ;
-
-    memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
+    playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
 
     CmdGenericPtr ptrTree;
     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),



More information about the vlc-commits mailing list