Bug 117623

Summary: Memory leak in halbackend.cpp
Product: [Frameworks and Libraries] kio Reporter: Chris Spiegel <cspiegel>
Component: mediaAssignee: Kevin Ottens <ervin>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Chris Spiegel 2005-12-03 21:08:07 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
Compiler:          gcc 3.3.6 
OS:                Linux

In kdebase/kioslave/media/mediamanager/halbackend.cpp, the libhal_get_all_devices() function is used twice.  The memory returned by this function needs to be freed with libhal_free_string_array().  The two instances are in HALBackend::~HALBackend() and  HALBackend::ListDevices().
Comment 1 Kevin Ottens 2006-06-15 23:37:13 UTC
SVN commit 551884 by ervin:

Avoid to leak devices lists.

Thanks for pointing this.
BUG: 117623


 M  +4 -0      halbackend.cpp  


--- branches/KDE/3.5/kdebase/kioslave/media/mediamanager/halbackend.cpp #551883:551884
@@ -84,6 +84,8 @@
             }
         }
 
+        libhal_free_string_array( halDeviceList );
+
         DBusError error;
         dbus_error_init(&error);
         libhal_ctx_shutdown(m_halContext, &error);
@@ -173,6 +175,8 @@
     for (int i = 0; i < numDevices; i++)
         AddDevice(halDeviceList[i], false);
 
+    libhal_free_string_array( halDeviceList );
+
     return true;
 }