From: RĂ©mi Duraffort Date: Wed, 1 Apr 2009 18:24:54 +0000 (+0200) Subject: Fix memleaks. X-Git-Tag: 1.0.0-pre2~282 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e5f21614f4212b7d4370411a0c07302ee3f673bc;p=vlc Fix memleaks. --- diff --git a/modules/misc/probe/hal.c b/modules/misc/probe/hal.c index 28fec81fd4..7bb6dcbb5d 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