[vlc-devel] commit: Fix memleaks. ( Rémi Duraffort )
git version control
git at videolan.org
Wed Apr 1 20:34:02 CEST 2009
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Apr 1 20:24:54 2009 +0200| [e5f21614f4212b7d4370411a0c07302ee3f673bc] | committer: Rémi Duraffort
Fix memleaks.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e5f21614f4212b7d4370411a0c07302ee3f673bc
---
modules/misc/probe/hal.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/modules/misc/probe/hal.c b/modules/misc/probe/hal.c
index 28fec81..7bb6dcb 100644
--- a/modules/misc/probe/hal.c
+++ b/modules/misc/probe/hal.c
@@ -67,11 +67,11 @@ vlc_module_end ()
static int Open( vlc_object_t *p_this )
{
device_probe_t *p_probe = (device_probe_t *)p_this;
- DBusError dbus_error;
- DBusConnection *p_connection;
- probe_sys_t *p_sys;
+ DBusError dbus_error;
+ DBusConnection *p_connection;
+ probe_sys_t *p_sys;
- p_probe->p_sys = p_sys = (probe_sys_t*)malloc( sizeof( probe_sys_t ) );
+ p_probe->p_sys = p_sys = malloc( sizeof( probe_sys_t ) );
p_probe->p_sys->i_devices = 0;
p_probe->p_sys->pp_devices = NULL;
@@ -83,28 +83,29 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_ctx )
{
msg_Err( p_probe, "unable to create HAL context") ;
- free( p_probe->p_sys );
+ free( p_sys );
return VLC_EGENERIC;
}
p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error );
if( dbus_error_is_set( &dbus_error ) )
{
msg_Err( p_probe, "unable to connect to DBUS: %s", dbus_error.message );
- dbus_error_free( &dbus_error );
- free( p_probe->p_sys );
- return VLC_EGENERIC;
+ goto error;
}
p_sys->p_connection = p_connection;
- libhal_ctx_set_dbus_connection( p_probe->p_sys->p_ctx, p_connection );
- if( !libhal_ctx_init( p_probe->p_sys->p_ctx, &dbus_error ) )
+ libhal_ctx_set_dbus_connection( p_sys->p_ctx, p_connection );
+ if( !libhal_ctx_init( p_sys->p_ctx, &dbus_error ) )
{
msg_Err( p_probe, "hal not available : %s", dbus_error.message );
dbus_connection_unref( p_connection );
- dbus_error_free( &dbus_error );
- free( p_sys );
- return VLC_EGENERIC;
+ goto error;
}
return VLC_SUCCESS;
+error:
+ dbus_error_free( &dbus_error );
+ libhal_ctx_free( p_sys->p_ctx );
+ free( p_sys );
+ return VLC_EGENERIC;
}
/*****************************************************************************
@@ -115,6 +116,7 @@ static void Close( vlc_object_t *p_this )
device_probe_t *p_probe = (device_probe_t *) p_this;
probe_sys_t *p_sys = p_probe->p_sys;
dbus_connection_unref( p_sys->p_connection );
+ libhal_ctx_free( p_sys->p_ctx );
free( p_sys );
}
#if 0
More information about the vlc-devel
mailing list